In Zapier I am building a zap that grabs a new webhook from quickbooks, compares it to a database and sends it to a website if it exists. Everything works except for one part.The bit of JavaScript that pulls a unique ID from a payload only takes the last result from a payload and does not process as separate values.
inputData.cleanID = webhookInputBodyHere //this is the input from zapier that gives the webhook body
if(inputData.cleanID == null){
var listArray = [];
} else{
var listArray = inputData.cleanID.split("},{");
}
var output = [];
var arrayNos = listArray.length;
var i = 0;
do{
var thisItem = new String(listArray[i]);
var thisItemObj = {};
var getEachId = thisItemObj.record = thisItem;
output.push({getEachId});
i++;
}
while (i < arrayNos);
Payload example 1 (multi-item hook)
{"eventNotifications":[{"realmId":"SOMEID","dataChangeEvent":{"entities":[
{"name":"Estimate","id":"34371","operation":"Update","lastUpdated":"2019-10-09T13:04:27.000Z"},
{"name":"Estimate","id":"34369","operation":"Update","lastUpdated":"2019-10-09T13:04:06.000Z"},
{"name":"Estimate","id":"34370","operation":"Update","lastUpdated":"2019-10-09T13:04:18.000Z"}]}}]}
Payload example 2 (single hook):
{"eventNotifications":[{"realmId":"315179876","dataChangeEvent":{"entities":[
{"name":"Estimate","id":"34370","operation":"Update","lastUpdated":"2019-10-09T13:04:18.000Z"}]}}]}
I contacted support and they suggested picking off the child key "entities" or "entities.id" both of which failed to do the job. I also tried using this option from the stacks and it didn't work anymore.
For non-zapier users you can create a free account to get an idea of what I'm talking about here by creating a new zap and choosing "zapier webhook" as trigger and "zapier code" as an action.
Hook time in quickbooks developer set to minimum which is 1 minute, if I could change that it would fix everything, but that doesn't seem to be an option.
So to summarize:
My webhook pulls a payload of 1 or more entities - TRIGGER
----See example 1 or 2----
Zapier processes the payload all together as a single value - ISSUE
----If example 1 is the payload my code would result in example 2 only----
I need each "entities" processed separately - DESIRED OUTPUT
----example 1 should output 3 seperate entities for to be processed in the zap----
I then want the zap to run for each separate entities.ID - FINAL RESULT