0

We are using zapier to push an invoice from Quickbooks Online (QBO) to ShipStation (SS). Everything is mapped fine except the SKU field (which for some reason QBO doesn't pass). So I created a lookup using a multi-zap and the Formatter Utility to match the description to a table of description/skus I made.

The limitation is that the Formatter Utility will only run once and not iterate through the payload array. Tech support told me this could be done with the code utility, but I'm not sure how to do it. Ideas?

jöhg
  • 212
  • 2
  • 12
  • Hey there! Typically, the best way to receive support is through the contact@ email, but happy to go through some of the code stuff here. Zapier Code can run both Python and Javascript, do you have a preference? – xavdid Dec 13 '16 at 21:11
  • I think JavaScript is more accessible for people and more widely supported. – jöhg Dec 14 '16 at 01:14
  • Great, makes sense. I looked through how arrays actually get sent along and the easiest thing is probably to make a second zap that catches a webhook and does 1 SS input per SKU. If that makes sense and you're cool with that, I can post an answer with that code. – xavdid Dec 14 '16 at 03:09
  • I'm not sure how to do that, but it sounds like a great option if you can make it work. Thank you so much for your help!! – jöhg Dec 14 '16 at 18:56

1 Answers1

1

Ok, so the best approach here will be to have 2 different zaps.

Zap A will move have a QBO trigger, go through your filters, and the last step will be a Code action. Zap B will have a "Catch Webhook" trigger and a ShipStation action. Let's go through them.

Zap A has a code step that takes input data. This'll be all of your SKUs separated by commas.

The code step will look something like this:

var skus = inputData.skus.split(',') // now it's an actual array
var otherZapUrl = 'https://zapier.com/catch/12345'

var lookupTable = {
  1: 'New York',
  2: 'Chicago',
  3: 'Los Angeles'
}

skus.map(function(sku){
  var payload = {
    sku: lookupTable[sku] || 'default',
    // other data you want to send along
    // name: inputData.name
  };
  fetch(otherZapUrl, {method: 'POST', body: JSON.stringify(payload)});
})

return [{status: 'ok'}] // this is so the editor doesn't complain

Your second zap will catch the webhook and fill out the SS fields you expect. Hopefully that's straightforward.

As for what you need to do, you'll need to redo your lookup table in javascript (sorry) and replace the otherZapUrl to that of the Zap B endpoint. Also, make sure you specify all of the data you want to pass onto SS in the code's inputData object.

How's that look?

xavdid
  • 5,092
  • 3
  • 20
  • 32
  • 1
    This looks great and like it will work ... and that it will require quite a bit of time and tinkering to squash all the bugs. I'll attempt and update here when I'm done. Thanks @xavdid! – jöhg Dec 16 '16 at 20:06
  • Great. Let me know if theres anything else you need! – xavdid Dec 17 '16 at 22:47
  • I'm working on this and can't figure out how to match the description for each line item that is coming from QBO (zapier refers to this object as 'Line Sales Item Line Detail Item Ref Name') to the SKU. I assume that inputData.skus.split will split 'Line Sales Item Line Detail Item Ref Name' into a js array. Doesn't the lookupTable need to have two elements, a description (the object we are catching from QBO) and a corresponding table of SKUs to match against? I'm uncertain how to use your function to link the array object to the SKUs I need to hard-code into the code step. – jöhg Jan 29 '17 at 00:33