Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Join two arrays in Logic Apps

I have two variables as Arrays in Logic app Ex;

 Variable A=["A","B"]
    Variable B=["C","D"]

I want to combine both and return

 Variable 9=["A","B","C","D"]
like image 896
prasy Avatar asked Sep 02 '25 06:09

prasy


1 Answers

Use the union function to combine two arrays:

union(variables('arr1'), variables('arr2'))

EDIT - add version to retain duplicates:

This will produce an array that removes duplicate entries. To retain the duplicates, use the join function to convert the arrays to strings:

join(variables('arr1'),',')

Next use concat to create a single string:

concat(variables('arr1String'),',',variables('arr2String'))

Finally, use split to convert the concatenated string to an array:

split(variables('arrStringsConcat'),',')

It gets pretty messy, but all together as a single statement:

split(concat(join(variables('arr1'),','),',',join(variables('arr2'),',')),',')
like image 110
Joel Cochran Avatar answered Sep 05 '25 00:09

Joel Cochran