Hello everyone! Is there a way to get rid of empty lists? I attempted to use `reject(a!isNullorEmpty, RESULT)`, but I encountered the following error: (Image 2).
Image 2
Discussion posts and replies are publicly visible
Did you give a!flatten a try?
docs.appian.com/.../fnc_array_a_flatten.html
Yes, but I need to preserve the inner list of tasks, and after using `a!flatten`, I obtain a general list of tasks. Is there a way to preserve the lists and eliminate the empty ones?
By any chance did you try reject( fn!isnull, Result) ??
Appian is bad at supporting list of list, unless you involve a map. You can remove the empty values directly when you are building this output using the reject() function or adding an if() condition to check if the value is nullorempty, if yes, then just add {} as the output for that iteration. Appian cannot print in a list unless all are {}
Try with this (from localtmp to the end , replace the name of your list)
a!localVariables( local!inputArray: {1,2,3,4,5,6,7,8,9,10,"","","",""}, local!totalArray: length(local!inputArray), local!maximumPerArray: 5,
local!amountArrays: ceiling(local!totalArray / local!maximumPerArray), local!iterationArray: enumerate(local!amountArrays), local!res: a!forEach( items: local!iterationArray, expression: with( local!leftAmountToCut: fv!item * local!maximumPerArray, local!rightAmountToCut: local!totalArray - ((fv!item + 1) * local!maximumPerArray),
rdrop( ldrop( local!inputArray, local!leftAmountToCut ), if(local!rightAmountToCut < 0, 0, local!rightAmountToCut) ) ) ), local!tmp: a!forEach( items: local!res, /*expression: if(count(reject(fn!isnull,union(fv!item, fv!item)))>0, union(fv!item, fv!item),null)*/ expression: count(reject(fn!isnull,union(fv!item, fv!item)))>0 ), index(local!res, wherecontains(true, local!tmp))
)