Well,
I want to compare the elements of two Arrays in Appian. I have the image in my mind, but i can't do it in Appian.
The example is like this:
We have 2 Arrays:
The return that I deserve is:
True,False,True,False, True
I think it can be do it with forEach and Ifs, but I cant do it.
Actually I have got this:
load( local!Array1: {100,200,300}, local!Array2: {100,200,300}, a!forEach( items: local!Array1 a!forEach( items: local!Array2 expression: if (local!Array1 = local!Array2, true, false) ) ) )
With this ERROR: Expression evaluation error: Syntax error. Details: Expression evaluation error at function a!forEach parameter 2 [line 17]: Missing right parenthesis in expression, found 'expression'
Thanks for your time.
Discussion posts and replies are publicly visible
Hey - try this:
a!localVariables( local!Array1: {100,200,300,400,700}, local!Array2: {100, 100, 300, 500,700}, a!forEach( items: fn!merge(local!Array1,local!Array2), expression: fv!item[1]=fv!item[2] ) )
The key to this is to use the merge() function which creates a list of lists (that is, it takes the first item in your first array and pairs it with the first item in your second array, and then the second with the second...and so forth)
It works!! but With forEach it can't be do it??
I'm not sure what you question is. But in case this is what you meant...here's another solution:
a!localVariables( local!Array1: {100,200,300,400,700}, local!Array2: {100, 100, 300, 500,700}, a!forEach( items: local!Array1, expression: fv!item=local!Array2[fv!index] ) )
Or...if you want to compare every item in Array1 with every item in Array2:
a!localVariables( local!Array1: {100,200,300,400,700}, local!Array2: {100, 100, 300, 500,700}, a!forEach( items: local!Array1, expression: with( local!currentValue: fv!item, a!forEach( items: local!Array2, expression: fv!item=local!currentValue ) ) ) )
I think second option it's exactly what I deserve, thank you so much!!