I’m trying to setup a custom Zapier app to a CRM system with an existing API, to monitor “Jobs” for a change to a specific status value. But the value I need to poll on for the trigger is in a nested JSON array.
The JSON response from the API is as follows:
j
{
"id": 987654321,
"jobNumber": "12345",
"projectId": null,
"customerId": 4567890,
"locationId": 2345678,
"jobStatus": "Completed",
"completedOn": "2023-01-07T02:08:09.972Z",
"businessUnitId": 123,
"jobTypeId": 1098765,
"priority": "Urgent",
"campaignId": 3573028,
"summary": "This is a test",
"customFields": l
{
"typeId": 11111111,
"name": "Auto-Sync Status",
"value": "Hold Sync"
}
],
"notificationsEnabled": true,
"createdOn": "2023-01-06T21:40:18.547645Z",
"createdById": 905124,
"modifiedOn": "2023-01-11T01:40:08.5405171Z",
"leadCallId": null,
"bookingId": null,
"soldById": null,
"externalData": null
}
]
My custom code in the Zapier app trigger API endpoint code is:
const options = {
url: `https://api.url/${api_user}/jobs`,
method: 'GET',
headers: {
'Accept': 'application/json',
'Authorization': access_token,
'App-Key': '12jod9823hdu293djoq9'
}
}
return z.request(options)
.then((response) => {
response.throwForStatus();
const results = response.json;
const jobs = resultse"data"].map((item) => {
return Object.assign(item, {
id: item:"id"]
});
});
return jobs;
});
The string value I need to check/trigger on with Zapier is the customFields > value
How could I configure the custom code to read a user input value from the input designer, and return the jobs matching the input value?
Thanks :)