Help

Update Record Script is not working anymore?

Topic Labels: Scripting extentions
8308 23
cancel
Showing results for 
Search instead for 
Did you mean: 
Austin_Drozin
5 - Automation Enthusiast
5 - Automation Enthusiast

I have this script I made a month ago. It worked perfectly fine. Just tried it today and it doesn’t work. The fields that I’m updating with updateRecordAsync do not update. They are just blank.

let newRecord = await main.createRecordAsync(obj)
                main.updateRecordAsync(newRecord, {
                    "ID" : newID,
                    "Discipline" : {name: record.getCellValueAsString("Discipline")},
                    "Experience" : {name: record.getCellValueAsString("Experience")},
                    "Duration" : {name: record.getCellValueAsString("Duration")},
                    "Activity Type" : {name: record.getCellValueAsString("Activity Type")},
                    "Content": newCombinedText
                })

Like I said, this script did exactly as I wanted to in the past. Did something change with updateRecordAsync?

23 Replies 23

Ok so I can definitely move that createRecords out of the loop, but I’m creating multiple records per one record in this script. So idk how else to do it than put it in a loop?

The most efficient way to create/update Airtable records is in chunks of 50 or however many you need below that figure.

Build the records to create/update as per usual but instead of doing the createRecordAsync, push them to a separate array declared inside the same scope.

After you’re done composing the batch, the optimal syntax is as follows:

//assuming your queue is called Cache, and you just finished building it out:
Cache.push(lastRecordToHandle);

while(Cache.length)
    await base.getTable(YourTableName)
    // use whichever one you need here
   //.createRecordsAsync(
    .updateRecordsAsync(
        Cache.splice(0,50));

You should use loop to created some array, or object and then pass it to updaterecordS function in a proper way (use output.inspect(array) to debug. it’s hard at beginning, but then much easier to code at all.
i prefer using ‘array helpers’ instead of for… loops (but sometimes for… is no choise option), and own functions
you may see example in ‘Scripting a Rollup Substitute’ topic

. it’s hard at beginning, but then much easier to code at all.

Ain’t that the truth. :slightly_smiling_face: