Help

Re: Error: Request exceeds maximum batch size limit of 100 items

4517 3
cancel
Showing results for 
Search instead for 
Did you mean: 
Kim_Zhou
6 - Interface Innovator
6 - Interface Innovator

Hi, Does anyone know how to fix this error my script is throwing? I originally used the script function to avoid the 100 record limit of find records…I put stars around the line where the script has issues.

let inputConfig = input.config();
let table = base.getTable("Companies"); 
let records = inputConfig.triggerRecords
let interactionDate = new Date(inputConfig.interactionDate)

let updates = new Array

**let companyRecords = await table.selectRecordsAsync({**
**    recordIds: records**
})

for (let companyRecord of companyRecords.records) {
    let companyInteractionDate = new Date(companyRecord.getCellValue("Date of Last Interaction"))
    if(companyInteractionDate.getTime() < interactionDate.getTime()){
        updates.push({
            id: companyRecord.id,
            fields: {
                "Date of Last Interaction": interactionDate
            }
        })
    }
    else{
        updates.push({
            id: companyRecord.id,
            fields: {
                "Date of Last Interaction": companyInteractionDate 
            }
        })
    }
}

while (updates.length > 0) {
    await table.updateRecordsAsync(updates.slice(0, 50));
    updates = updates.slice(50);
}

Thanks!!

5 Replies 5

This limit is documented here.

The workaround is to requests records in batches of 100. So if you have 200 record IDs and want those records, you need to make two requests–one for the first hundred and another for the second hundred.

Thank you kuovonne! I think this makes sense, but is there a workaround where I am not manually changing how many times I make that request or copy-and-pasting the code chunk, say, 10 times to account for the maximum number of entries I expect to be entered at once? In other words, since I cannot anticipate the largest number of record IDs I would need to pull is there another way around this limit?

Setup a loop based on the number of record IDs in your initial array. There are many different ways of doing this in JavaScript. Different people prefer different methods.

Thanks! Do you have an example I could reference? I’m new to scripting so I’m not familiar with how exactly to go about this but have attached my attempt (it threw an error).

let inputConfig = input.config();
let table = base.getTable("Companies"); 
let records = inputConfig.triggerRecords
let interactionDate = new Date(inputConfig.interactionDate)

let updates = new Array

updates.forEach(element => {
  let companyRecords = await table.selectRecordsAsync({
      recordIds: records
  })
});

for (let companyRecord of companyRecords.records) {
    let companyInteractionDate = new Date(companyRecord.getCellValue("Date of Last Interaction"))
    if(companyInteractionDate.getTime() < interactionDate.getTime()){
        updates.push({
            id: companyRecord.id,
            fields: {
                "Date of Last Interaction": interactionDate
            }
        })
    }
    else{
        updates.push({
            id: companyRecord.id,
            fields: {
                "Date of Last Interaction": companyInteractionDate 
            }
        })
    }
}

while (updates.length > 0) {
    await table.updateRecordsAsync(updates.slice(0, 50));
    updates = updates.slice(50);
}


Hi,

I would suggest to use array function ‘map’ instead of for and foreach, and ‘filter’ to check triggerrecords.includes.
But it feels like you are trying to script something doable without code, by AT built-in ‘Date modified’(with selected fields to watch) and lookup. Why don’t you just add Interaction date field from ‘Interactions’ into ‘Company’ as lookup?