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