Skip to main content
yahairat
Participating Frequently
Feb 27, 2024 11:03 PM UTC
Solved

Remove empty Empty List of Variant

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

harshitb6843
Brainy
Feb 28, 2024 6:17 AM UTC

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 {}

5 replies

mathieud0001
Genius
Feb 28, 2024 12:05 AM UTC

Did you give a!flatten a try?

docs.appian.com/.../fnc_array_a_flatten.html

yahairat
yahairatAuthor
Participating Frequently
Feb 28, 2024 12:15 AM UTC

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? 

harshitb6843
Brainy
Feb 28, 2024 6:17 AM UTC

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 {}

Known Participant
Feb 28, 2024 4:32 AM UTC

By any chance did you try reject( fn!isnull, Result) ??

davidj137213
Brainy
Feb 28, 2024 10:25 AM UTC

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))

)