cancel
Showing results for 
Search instead for 
Did you mean: 

Does snaplogic have a mechanism like includes method? array.includes("value")?

acesario
Contributor II

Does snaplogic have a mechanism like includes method?

e.g.
“AwardStatus”:[“ACCEPTED”,“OFFERED”,“CANCELED”],

Something like
$AwardStatus.includes(“CANCELED”) ?

2 REPLIES 2

Harsha3
New Contributor III

Hi Acesario,

We don’t have direct method like .contains() like in the case of string . However we can use the indexOf functionality to find whether the particular element is present in an array or not .

$AwardStatus.indexOf(“CANCELED”)==-1?“Absent”:“Present”

Where -1 here means the given element is not present in an array else it will be present . Hope this clarifies the answer .

Also please refer the below documentation to explore more about array manipulation techiniques.

https://docs-snaplogic.atlassian.net/wiki/spaces/SD/pages/1438091/Array+Functions+and+Properties

bojanvelevski
Valued Contributor

Hello @acesario ,

You can also use the following expression => .filter(x=>x == “CANCELED”).length != 0
If the AwardStatus contains “CANCELED” the expression will produce “true”, if not, it will produce “false”.

Best regards,

Bojan Velevski