Add null to array

Hello Appian People,

Do you have any idea how to to implement this case:

So for example variable arr must be the same length value of variable value:

local!arr:{1,2,3}

local!value: {"a","b","c"}

But if incase of variable arr is not equal value size of variable value. It needs to add null value on the local!arr  , example:

local!arr:{1}

local!value: {"a","b","c"}

local arr expected ouput must be : local!arr{1,null,null}

another case example:

local!arr:{1,2}

local!value: {"a","b","c","d"}

local arr expected ouput must be : local!arr{1,2,null,null}

  Discussion posts and replies are publicly visible

Parents
  • Hi,

    You can try this solution, this will add null values to the array which has a smaller number of values into it.

    a!localVariables(
    local!arr: { 1 },
    local!value: { 1, 3, 5 },
    local!diff: if(
    a!isNullOrEmpty(difference(local!arr, local!value)),
    difference(local!value, local!arr),
    difference(local!arr, local!value)
    ),
    if(
    a!isNullOrEmpty(local!diff),
    local!diff,
    if(
    a!isNullOrEmpty(difference(local!arr, local!value)),
    append(
    local!arr,
    a!forEach(items: local!diff, expression: null())
    ),
    append(
    local!value,
    a!forEach(items: local!diff, expression: null())
    ),
    )
    )
    )

Reply
  • Hi,

    You can try this solution, this will add null values to the array which has a smaller number of values into it.

    a!localVariables(
    local!arr: { 1 },
    local!value: { 1, 3, 5 },
    local!diff: if(
    a!isNullOrEmpty(difference(local!arr, local!value)),
    difference(local!value, local!arr),
    difference(local!arr, local!value)
    ),
    if(
    a!isNullOrEmpty(local!diff),
    local!diff,
    if(
    a!isNullOrEmpty(difference(local!arr, local!value)),
    append(
    local!arr,
    a!forEach(items: local!diff, expression: null())
    ),
    append(
    local!value,
    a!forEach(items: local!diff, expression: null())
    ),
    )
    )
    )

Children