cancel
Showing results for 
Search instead for 
Did you mean: 

Check if field inside array has value and route the output

Igor_Bozhinovsk
New Contributor III

[
{
“items”: [
{
“test”: " ",
“id”: 1
},
{
“test”: “test”,
“id”: 2
}
]
}
]
Currently we have an array like this , we need to route the output from the Router based on the test field , if there is a value the output should go to the upper branch if there is not value for the test field the output should go to the lower branch.

Is there any array method or something else that can be used to achive this ?

3 REPLIES 3

SpiroTaleski
Valued Contributor

@Igor_Bozhinovski

The simplest way to do the routing is by splitting the array using the JSON Splitter Snap, and then in the Router Snap add the logic where you will route the records based on the “test” field(if it is empty or not).

BR,
Spiro Taleski

Thanks Spiro , but for now we need to check the element value inside in the array.

Regards,
Igor

SpiroTaleski
Valued Contributor

@Igor_Bozhinovski

If you need to perform routing using the Router Snap(as you mentioned in the post), then you need the data to be flatten.

You can split the data, perform routing and then revert back in array.

Additionally, you can use the Map Function in order to go/iterate trough the array and check elements inside.

BR,
Spiro Taleski