I'm receiving an error: “Expression evaluation error at function 'union&

I'm receiving an error: “Expression evaluation error at function 'union' [line 15]: Cannot compare type List of Number (Integer)”

I'm using the following expression to return a list of application ids, which is then passed through a ‘union’ command to remove duplicate ids. The error appears to manifest when the list of returned application ids reaches a certain size (around about 40 ids), less than that the expression runs as expected.

Any suggestions why this maybe happening?

=with(
local!tasks: a!queryProcessAnalytics(
report: cons!LUA_OPEN_TASKS_REPORT_DOCUMENT,
contextProcessModels: cons!LUA_OPEN_TASKS_PROCESS_MODELS,
query: a!query(
filter: a!queryFilter(
field: "c10",
operator: "in",
value: ri!user
),
pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1)
)
),

union(local!tasks.data.c7, local!tasks.data.c7)
)

The output query format is:
[label:Process,field...

OriginalPostID-154528

OriginalPostID-154528

  Discussion posts and replies are publicly visible

  • ...:c3,drilldownField:dp3,configuredFormatting:NORMAL_TEXT,configuredDrilldown:PROCESS_DASHBOARD]; [label:From,field:c1,drilldownField:dp1,configuredFormatting:USER_NAME,configuredDrilldown:]; [label:Assignee(s),field:c10,drilldownField:dp10,configuredFormatting:USER_OR_GROUP_NAME,configuredDrilldown:]; [label:Owner,field:c9,drilldownField:dp9,configuredFormatting:USER_NAME,configuredDrilldown:]; [label:Received,field:c2,drilldownField:dp2,configuredFormatting:DATE_TIME,configuredDrilldown:]; [label:Completed,field:c11,drilldownField:dp11,configuredFormatting:DATE_TIME,configuredDrilldown:]; [label:Status,field:c5,drilldownField:dp5,configuredFormatting:TASK_STATUS,configuredDrilldown:]; [label:Application Id,field:c7,drilldownField:dp7,configuredFormatting:NUMBER,configuredDrilldown:];
    [label:Task Id,field:c12,drilldownField:dp12,configuredFormatting:NUMBER,configuredDrilldown:]; [label:Terminate Application,field:c13,drilldownField:dp13,configuredFormatting:NORMAL_T...
  • ...EXT,configuredDrilldown:CUSTOM_URL];
    [label:Process Id,field:c14,drilldownField:dp14,configuredFormatting:NUMBER,configuredDrilldown:]; [label:Name,field:c15,drilldownField:dp15,configuredFormatting:NORMAL_TEXT,configuredDrilldown:]; [label:parentProcessId,field:c16,drilldownField:dp16,configuredFormatting:NUMBER,configuredDrilldown:], errorMessage=]
  • If data that you are retrieving is integer type, then do the casting as follows.

    union(tointeger(local!tasks.data.c7), tointeger(local!tasks.data.c7))
  • Just note that, this type of error is more prevalent with functions such as difference, union, wherecontains, contains, and etc. where all inputs required must be of same type. And appropriate casting needs to be done prior to execution at design time to avoid an error.
  • @stephens To add to Amit's explanation, this type casting is especially needed when we are dealing with the data returned by querying process analytics. So far from my experience, I have observed that data returned by querying process analytics is mostly in the list format. At times, when this data is passed to some Appian functions, implicit type casting will be done whereas an explicit type casting is needed when Appian doesn't perform implicit casting for us. Also I would like to add that we should always be aware of the type of data we have in hand using typeof() and typename(), and then perform an explicit cast accordingly as per the need basis.
  • union(tointeger(local!tasks.data.c7), tointeger(local!tasks.data.c7)) seems to have corrected the problem, thanks to both of you.