Skip to main content
yahairat
February 27, 2024
Solved

Remove empty Empty List of Variant

  • February 27, 2024
  • 5 replies
  • 0 views

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

Best answer by harshitb6843

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
February 28, 2024

Did you give a!flatten a try?

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

yahairat
yahairatAuthor
February 28, 2024

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
February 28, 2024

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

February 28, 2024

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

davidj137213
February 28, 2024

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

)