Hello,
I've created a datasubset using a!foreach. Now want to filter the data on the datasubset depending on the value for one field. Can you please suggest on this?
a high level snippet is below. Below rule returns a datasubset & on that datasubset I am trying add a filter.
todatasubset(
a!forEach( items: rule!Irulename(), expression: 'type!{urn:com:appian:types:cdt}|cdt_name'(fields:, completed: rule!newRuleToupdateafield ))
)
Discussion posts and replies are publicly visible
I'm not sure what the requirements are of the "filtering" you want to perform, but in general, you can use a!forEach() to loop over items in any array (including dictionaries, CDTs, etc), and any items that don't match the condition you want, just return the empty set "{}".
Note: If there's a chance that all rows may be filtered out under any condition, you need to wrap the whole thing in "a!flatten()" as well, since otherwise using the above technique would return a list of empty sets specifically when all results are empty sets (otherwise it performs as expected).
As an example, try this in a blank interface:
a!localVariables( local!options: {"A","B","C","D"}, local!selected: null, local!data: todatasubset( a!flatten( fn!reject( fn!isnull, a!forEach( items: local!options, expression: if( fv!item=local!selected, null, { data: fv!item } ) ) ) ) ), a!columnsLayout( columns: { a!columnLayout( contents: { a!dropdownField( label: "Filter Out", choiceLabels: local!options, choiceValues: local!options, placeholder: "-- Select --", value: local!selected, saveInto: local!selected ) } ), a!columnLayout( contents: { a!richTextDisplayField( label: "Result", value: a!forEach( items: local!data, expression: { a!richTextItem( text: fv!item.data ), char(13) } ) ) } ) } ) )
Thank you Mike. Your suggestion was helpful.
Thank you Chris. Your suggestion was helpful.
Thanks! I would also appreciate a "verify answer" click if you're satisfied.