This topic was automatically generated from Slack. You can find the original thread here.
Mohammed Zeeshan : Hi!
I am trying to update an airtable record using 2 event steps 1. listing records 2. updating records
Listing records returns the details as expected but when i try to update the record by mapping the record from the previous step, it doesn’t show up
I tried manually adding the record-id but it returned 422. I haven’t yet added the fields to be updated at this point. What would be missing? can anyone point to the right direction? Thanks
Dylan Sather (Pipedream) : typically the 422 error from Airtable suggests that something about the record update payload is malformed.
Take a look at this example - I format the update request in the first step, and pass that to the next step as the value of the Records param. I’ve turned structured mode Off in this example, which allows me to pass an array of record updates directly from a previous step (see our docs on structured params for more info).
Dylan Sather (Pipedream) : ```
this.records = [
{
fields: {
“YOUR FIELD”: “YOUR VALUE”,
},
id: steps.YOUR_STEP_THAT_FINDS_THE_RECORD.RECORD_ID, // replace with the variable reference to the record ID
},
]
Dylan Sather (Pipedream) : I believe you’ll just need to fill in the record ID with the reference to the record returned by your find step. Am I misunderstanding you?
Dylan Sather (Pipedream) : once you’ve correctly formatted the update payload with the fields and id, you should be able to pass that to the update step
Dylan Sather (Pipedream) : great! Yes, with the Airtable API, since they expect that format for updating records, you’ll need to get your update request into that form
Mohammed Zeeshan : Got it! Thanks. But again, i was wondering how could we update fields here while it doesn’t show the field name like Zapier
Basically i simply want some strings to go into a field in airtable
Dylan Sather (Pipedream) : Currently there is not an easy way for us to infer the fields like Zapier does, but that’s great feedback. I’ll look into their approach.
Dylan Sather (Pipedream) : Airtable expects an array of objects. Unfortunately what you’re passing isn’t valid JavaScript (you’re trying to define an object without wrapping it in { }. You should be able to pass the array of objects directly inside of the Records param, though:
{{ [
{
fields: {
"YOUR FIELD": "YOUR VALUE",
},
id: steps.YOUR_STEP_THAT_FINDS_THE_RECORD.RECORD_ID, // replace with the variable reference to the record ID
},
] }}
Adding values as recID works well and the airtable gets updated
but…
i want to add some strings from the previous steps which results in 422 error (yikes)