Issue in fn!union() to return unique values. Is there any other function available?

Certified Associate Developer

Hi Team,

Got confused while doing some calculations in Appain Expression rule. Added input and output below. i have tried fn!union() function but it was failing sine input was only one array.

Code: fn!union({ 1, 2, 2, 1, 3, 1, null, null }, {})

Sample i/p -> { 1, 2, 2, 1, 3, 1, null, null}

Expected o/p -> { 1, 2, 3} 

Current Appian Design:

Thanks and Regards,

Vigneshkumar Radhakrishnan

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hi,

    you want to use union() then you need to pass two parameter. and also you want to remove null values form output, then code should look like below

    a!localVariables(
      local!input1: { 1, 2, 2, 1, 3, 1, null, null},
      local!input2: { 1, 2, 2, 1, 3, 1, null, null},
      reject(a!isNullOrEmpty(_), union(local!input1, local!input2))
    )

Reply
  • 0
    Certified Senior Developer

    Hi,

    you want to use union() then you need to pass two parameter. and also you want to remove null values form output, then code should look like below

    a!localVariables(
      local!input1: { 1, 2, 2, 1, 3, 1, null, null},
      local!input2: { 1, 2, 2, 1, 3, 1, null, null},
      reject(a!isNullOrEmpty(_), union(local!input1, local!input2))
    )

Children
No Data