Hi ,
I want to update the local variable of the type List of Cdt based on a condition. For eg.
myCDT:{{name:"Albert",age:30,Dept:'Sales',Sal:10000},{name:"Beth",age:28,Dept:'HR',Sal:2000},{name:"Cindy",age:35,Dept:'Finance',Sal:2000},.................}
Dept:{"HR","Sales"}
I wanted to update the Sal of myCDT list found in the Dept variable.
I know we can do it with foreach() function, but I have to map each field in the CDT. I have around 50 fields in my actual CDT
Is there another way to implement this ? Please suggest.
Thanks in advance.
Discussion posts and replies are publicly visible
Hi,
You can try a!update() functionhttps://docs.appian.com/suite/help/21.4/fnc_array_a_update.html
Thanks,
Farnaz
can you please provide an example?
Would you please check the documentation before asking for examples.
docs.appian.com/.../fnc_array_a_update.html
yes Steven, I already checked the example.
I couldn't find an example for a list of CDT,
using wherecontains() function, i can find the indexes of the array which need to be updated.
For eg :
updatearray(
array:local!myCDT,
index:wherecontains(local!Dept,touniformstring(local!array.Dept),
value: ?
i am not sure how to update the Sal . I hope you understand my scenario.
the update function is not available in version 20.4. and looks like updateArray does not support CDT
For older versions, you can use this plugin
https://community.appian.com/b/appmarket/posts/cdt-manipulation
Then I would just use foreach to iterate the whole list and then conditionally modify that field.
As a further hint, you would need to use updateCdt() or updateDictionary() from the CDT manipulation plug-in, preferably inside the loops of an a!forEach loop. I note you commented you don't want to use a!forEach, but I believe your reasoning for that is superseded by the functionality contained in these update... functions.