cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to check condition and route

Darshita
New Contributor II

Hi,

I want to check the value of Description in each item in the below JSON and route seperately if all are same and seperately if theyโ€™re different. How can I do this?

[
{
โ€œSEGMENT1โ€: โ€œ104155โ€,
โ€œDESCRIPTIONโ€: โ€œEURโ€,
โ€œUNIQUE_IDโ€: โ€œ224โ€,
โ€œITEM_NUMBERโ€: โ€œ0113โ€
},
{
โ€œSEGMENT1โ€: โ€œ104154โ€,
โ€œDESCRIPTIONโ€: โ€œAEDโ€,
โ€œUNIQUE_IDโ€: โ€œ224โ€,
โ€œITEM_NUMBERโ€: โ€œ0103โ€
},
{
โ€œSEGMENT1โ€: โ€œ104153โ€,
โ€œDESCRIPTIONโ€: โ€œUSDโ€,
โ€œUNIQUE_IDโ€: โ€œ224โ€,
โ€œITEM_NUMBERโ€: โ€œ0090โ€
},
{
โ€œSEGMENT1โ€: โ€œ104153โ€,
โ€œDESCRIPTIONโ€: โ€œUSDโ€,
โ€œUNIQUE_IDโ€: โ€œ224โ€,
โ€œITEM_NUMBERโ€: โ€œ0014โ€
},
{
โ€œSEGMENT1โ€: โ€œEXTRA_EVENTโ€,
โ€œDESCRIPTIONโ€: null,
โ€œUNIQUE_IDโ€: null,
โ€œITEM_NUMBERโ€: null
}
]

Regards,
Darshita

2 REPLIES 2

dimche_saveski
New Contributor III

Hello @Darshita

You can use Group By Fields snap, and group your records by DESCRIPTION field , then downstream Router snap that will route records based on DESCRIPTION field.

Best Regards
Dimche Saveski

alchemiz
Contributor III

Is the array streaming document? So I put your array into an object Items

basically the objective is to have an array of description where length is equal to 1 meaning all have the same descriptions. See screenshots below

eval($Items.map((a)=> a[โ€˜DESCRIPTIONโ€™]).filter((x,y,z)=> z.indexOf(x) == y).length == 1)

image

image