I suddenly get an error while executing my script. “There was an unexpected error while executing your script”. It doesn’t say which one causes it. I only change my table name and change immediately the value on the gsctable variable.
let gsctable = base.getTable("CBD B2B DE 5");
let query = await gsctable.selectRecordsAsync();
let today = new Date();
let year = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(today);
let month = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(today);
let day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(today);
let todate = `${year}-${month}-${day}`;
let lw = new Date(today.getFullYear(), today.getMonth(),today.getDate()-7);
let ly = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(lw);
let lm = new Intl.DateTimeFormat('en', { month: '2-digit' }).format(lw);
let ld = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(lw);
let lastweek = `${ly}-${lm}-${ld}`;
for(let dates of query.records){
let todaycell = dates.getCellValue('EndDate'); //End Date
let lastweekcell = dates.getCellValue('StartDate');//Start Date
if(todate != todaycell){
await gsctable.updateRecordAsync(dates,{
"Update":todate
})
}
}