I have an external API using, which I’m getting a list of the items.
Items object/array is having a field name = title
I want to update only records for which title matches
AT also have a field name “title”
but this is not working as expected. it;s not aligning the correct records.
let table = base.getTable('Data');
let view = table.getView("CMS Data");
let query1 = await view.selectRecordsAsync({
sorts: [
{field: "Title"},
]
});
let response = await fetch('https://<api-url>/endpoint?_format=json', {
//method: 'GET',
});
let query = await response.json();
let peopleTable = base.getTable('Content');
for (var i in query) {
recordId = query1.records[i].id;
if( query1.records[i].getCellValue("Title") == query[i].title ) {
let cms_id = query[i].id;
await peopleTable.updateRecordAsync(recordId, {
"id": Number(cms_id),
})
}
}