Skip to main content
Participating Frequently
Dec 9, 2022 2:35 AM UTC
Question

A value is declared regular string in db and im using it in cdt

so lets say clothesType is declared as string in db. in a rule, i am iterating over this variable using for each loop. the problem is i can't declare the clothesType as an array as it would affect existing functionality. If i could, it would solve the problem. So, are there any built in appian functions that i can use to run a for each loop over a value that is accepting one value only?

    5 replies

    stefanhelzle0001
    Brainy
    Dec 9, 2022 7:33 AM UTC

    So you want to store something like a comma-separated list in a field? If yes, you can just use the split() function to turn that into a list of values.

    mikes0011
    Brainy
    Dec 9, 2022 5:35 PM UTC

    I'm unclear whether this is the use case OP was trying to describe (though it seems like one of the more likely options, to be fair).  I need to interject here that if someone is tempted to do this, they should strongly consider storing their list-of-values-in-text as a JSON string, to utilize the pre-built JSON conversion / parsing functionality, since even something as simple as a comma-separated list becomes a giant hassle to implement and debug the second you need it to store user-entered text, etc.

    The Expression Guru
    Participating Frequently
    Dec 9, 2022 6:29 PM UTC

     

     this is getting me the correct behavior. but for my use case, i am running 35 id numbers in a for each loop to check if they are formatted correctly. 

    i.e. if i run the test case like this: 

    it will fail because it is not declared in the db as an array (and i can't modify it since its used else where as well). 

    so is there a way around this?