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

Create a conditional (ie: If value includes to this) function against an array

mlodge
Deputy Chef I
Deputy Chef I

New to Workat and I am working with a schema that has some nested arrays and I cant seem to figure out how to create a if condition that will be triggered if any option in the nested array contains the specific value.


Example:

create a if condition where "Interests" contains "swimming" so that the data in the schema below is picked up


{

"deliveryContext": {


"camper": {

"demographics": {

"address": "string",

"city": "string",

"state": "string",

"country": "string",

"phone": "string",

"postalCode": "string",

"email": "string",

"firstName": "string",

"lastName": "string",

}

"Interests": [

{

"id": "34",

"value": "biking"},

{id": "27",

"value": "biking"}.]

}

}

6 REPLIES 6

james-ng
Deputy Chef I
Deputy Chef I

hey RAYUDU ADDAGRALA the recipe worked with David Cornwell's json

{"deliveryContext": {"camper": {"demographics": {"address": "string","city": "string","state": "string","country": "string","phone": "string","postalCode": "string","email": "string","firstName": "string","lastName": "string","Interests": [{"id": "34","value": "biking"},{"id": "22","value": "swimming"}]}}}}


correctly picked up the second id "22" with value "swimming"

jgold
Deputy Chef I
Deputy Chef I
In the input field of the if step enter:
deliveryContext[โ€˜camperโ€™][โ€˜Intrestsโ€™].pluck(โ€˜valueโ€™).include?(โ€˜swimmingโ€™) and then setup the condition as โ€œis trueโ€. 

Notes:
  1. make sure to use formula mode
  2. deliveryContext is a datapill from a previous step. 
  3. Make sure to use actual single quotes (my phone doesnโ€™t put proper single quotes in an email)
  4. You need to handle cases where deliverContext is a nil object since using [โ€˜camperโ€™][โ€˜Intrestsโ€™] on a nil object will throw an error. 

Joel Gold
Principal
Doliotech
801-613-1115
Jgold@doliotech.com