Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Updating Records - Only updates 15 records then stops

Topic Labels: Scripting extentions
99 0
cancel
Showing results for 
Search instead for 
Did you mean: 

First, I want to say I am new to JavaScript so I could be doing something obviously wrong. I have a table that has user emails, and then linked fields to each “assignment” they submit. That is connected with an automation, when they submit a form, it links the record.

Now, I am trying to assign points to each user, with each assignment having a different point value.

let table = base.getTable("Assignment Tracker");
let query = await table.selectRecordsAsync();

for(let i = 0; i < query.records.length-1; i++){
    let cohort = query.records[i].getCellValueAsString('Cohort (from Students)');
    let email = query.records[i].getCellValue("Student Username (Email)");
    let points = 0;

   // I have more activities than this, just putting it here so you can see how each is structured.
    if(query.records[i].getCellValue("(1) Cold Intro Call")) points = points + 15;
    if(query.records[i].getCellValue("(1) Free to Paid")) points = points + 3;
    
    console.log(email + " " + points + " " + i + " " + cohort);
    await table.updateRecordAsync(query.records[i], { 'Points': points}); 

When I run this script, I get a console log of all 44 records, but it only updates about 15 records with point values. (the updaterecordasync)

Would anyone happen to know why this might be happening? Much appreciated!

UPDATE: I added await before table.updateRecordAsync and it fixed my problem. Want to leave this here for anyone to see in the future.

0 Replies 0