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, If you want to use union() then you are expected to pass two arrays, from your requirement, your code should look something like below,

    a!localVariables(
      local!input:{ 1, 2, 2, 1, 3, 1, null, null},
    union(local!input, local!input),
    
    
    )

  • 0
    Certified Associate Developer
    in reply to GopalK

    Yes, Agree but normally its look Appain was failed in sometimes of execution right. Assume if user are passing same data twice but Appian needs to handle this also right it union() passed one parameter then it return outputs instead of error as invalid parameter

    @appian

  • What does union mean? set of all unique elements from multiple sets. So, there should be more than one array to perform a union right? it is mentioned in the documentation on the Expression rule designer as well that atleast two arrays are required for union to work as expected although it can take n number of arrays. Consider this as sum of numbers which always require more than one number to execute.

    Now, you can try what other contributors suggested (passing the same array as second parameter) or you can fool Appian by passing an empty list as a second parameter which would also yield the same result.

    union({ 1, 2, 2, 1, 3, 1, null, null }, tointeger({}))

Reply
  • What does union mean? set of all unique elements from multiple sets. So, there should be more than one array to perform a union right? it is mentioned in the documentation on the Expression rule designer as well that atleast two arrays are required for union to work as expected although it can take n number of arrays. Consider this as sum of numbers which always require more than one number to execute.

    Now, you can try what other contributors suggested (passing the same array as second parameter) or you can fool Appian by passing an empty list as a second parameter which would also yield the same result.

    union({ 1, 2, 2, 1, 3, 1, null, null }, tointeger({}))

Children
No Data