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

How to fetch value from array?

Manigandan
New Contributor II

Hello Team,

I have the below array and I need to fetch the filename where active=1. Please can you help me on this.

โ€œarrayโ€ : [
{
โ€œactiveโ€: 0,
โ€œfileNameโ€: โ€œtest.pdfโ€
},
{
โ€œactiveโ€: 1,
โ€œfileNameโ€: โ€œtest1.pdfโ€
}
]

Thanks in advance!

2 REPLIES 2

marjan_karafilo
Contributor

Hi @Manigandan ,

You can use the Filter snap to filter out only active objects.

Please take a look at the attached pipeline.

00_Fetch_Active_2023_07_16.slp (4.6 KB)

Best regards,
Marjan

Hi @Manigandan,

@marjan.karafiloskiโ€™s solution will help you in this case.
If you want to keep everything in one mapper, then take a look at the array filter function:

Filter array

The expression would look something like this:

$array.filter(x=>x.active == 1)

Regards,
Bojan