How do I push an array of JavaScript objects to Airtable?

This topic was automatically generated from Slack. You can find the original thread here.

Luke : Hi! I’m trying to push an array of objects to Airtable. I’m only taking certain values from each object. I can get it to work for a single object in the array - does anyone know how I can get it to push the entire object?

$return_value is the array of objects

Dylan Sather (Pipedream) : take a look at this example workflow. First, I turn Structured Mode off for the Records param, which allows me to pass data to the Update Records action using data from a previous step.

In this case I’m passing {{steps.format_airtable_records.records}} , which I’ve formatted in in the format_airtable_records step above. This array of record / field updates is in the format Airtable expects.

Passing a reference to a previous step like this is normally my approach when passing complex sets of data to actions like this. Let me know if this makes sense.

Dylan Sather (Pipedream) :

Luke : Thanks ! This makes sense, although I’m still a little confused as to how to pass each value from the array?

Luke : For example, here it still formats as the first value in the array, so that’s all that gets passed

Luke :

Dylan Sather (Pipedream) : got it. How familiar are you with Node.js?

Luke : Pretty familiar!

Luke : Like comfortable with writing custom code for this

Dylan Sather (Pipedream) : awesome. In this code step, can you iterate over the incoming array of data to format an array of the Airtable updates?

Dylan Sather (Pipedream) : e.g. this.records = steps.get_github.$return_value.map(d => { return { fields: "Name": d.name } })

Dylan Sather (Pipedream) : (not sure if that’s exactly what you’re looking for, but that general idea)

Luke : Aha, that worked!

Luke : Thanks so much :slightly_smiling_face:

Dylan Sather (Pipedream) : great!