I have an expression rule with the following code
ri!createdBy, a!forEach( items: ri!createdBy, expression: rule!OBV_replaceNull( fv!item, loggedInUser() ) ) ),
I call it from an interface like this
rule!myER(createdby: cdtName.created_by), where cdtName is an array of cdt type
The problem is that every item in the resulting array contains all the values. So if it loops twice cdtname.created_by will look like this {username;username, username;username}. If I did just a save like this save(ri!createdBy, loggedInUser()) then it works fine.
Running the for each alone seems to return the correct result within the expression rule. However, it is once I add the save into the rule input that causes problems. Has anyone run into this problem and found a solution?
Discussion posts and replies are publicly visible
I think i didn't get the whole context but why don't you try to cast in the for each so every returning item would be of that CDT type.
IE.
a!forEach( items: local!yourVariable //whole cdt ? expression: 'type!{urn:com:appian:types:TSS}TSS_Test'(
id:fv!item.id,
field2:fv!item.field2,
username :rule!OBV_replaceNull(fv!item,loggedInUser())
)
The reason I can't do that it's because I'm not passing the whole CDT, I'm only passing one of the cdt fields (created_by) which is an array of text.
saveInto: { a!forEach( ri!cdtName, a!save( fv!item.createdBy, if( isnull( fv!item.createdBy ), loggedInUser(), fv!item.createdBy ) ) )}
can you try like above