Forum Discussion

Dawid_Zajdel's avatar
Dawid_Zajdel
New Contributor
6 years ago
Solved

Change nested arrays into one array

Hi,

I have a situation like below:

I have array "Allowance_Plan’ and in this array I could have many elements which also are arrays.
Child arrays as a elements contains objects.

In this case I have 2 arrays with 2 object in each of them.

As a final result I would like to receive one array “Allowance_Plan” which contains 4 objects. (2 from first child array and 2 from second child array)
Please suggest how to solve this problem.

  • I think you’re looking for the .concat() method on arrays. That method will concatenate its arguments into a single array. To pass the arrays as the arguments to the method, you can use the spread operator (...), like so:

    [].concat(...$['peci:Allowance_Plan'])
    

    Here’s an example pipeline:

    Community7041_2020_03_09.slp (3.5 KB)