auths
objectreturn
or this.key = 'value'
, pass input data to your code viaparams
, and maintain state across executions with$checkpoint.async
(event, steps) => {
}
this.records = [
{
fields: {
fieldName: "fieldValue",
fieldName2: 2,
},
id: "airtable_record_id",
}
]
Records to update. This action can accept an array with more than 10 record objects, it will iterate over the array, and hit the Airtable update_records endpoint with sets of top 10 records. Each of these objects should have one key, fields, which contains all of your record's cell values by field name. You can include all, some, or none of the field values.
The ID of the base API url.
The name of Airtable's table to update.
async
(params, auths) => {
}
const chunk = require('lodash.chunk');
const BATCH_SIZE = 10; // Airtable API allows to update upto 10 rows per request.
const records = JSON.parse(params.records);
if (!records || !records.length) {
console.log("No records found")
return
}
const size = records.length;
const response_records = []
async function updateRecords(data){
const config = {
method: "patch",
url: `https://api.airtable.com/v0/${params.base_id}/${encodeURIComponent(params.table_name)}`,
headers: {
Authorization: `Bearer ${auths.airtable.api_key}`,
},
data
};
return await require("@pipedreamhq/platform").axios(this, config);
};
const records_sets = chunk(records, BATCH_SIZE);
for (const records_set of records_sets) {
response_records.push(await updateRecords({ records: records_set }));
}
return response_records;