I have an automation that runs a script, when a record enters a view.
When I run the script as a test (in the automation setup mode), there’s never a problem. However, if the automation triggers, the script is always stopped by execution time limit.
Any idea how to fix this?
It’s usually only a couple of records int he view that triggers, so it shouldn’t be heavy computing at all.
//Copy Values to a linked field
//Declare tables
var activeTbl = base.getTable("Delivered");
var activeView = activeTbl.getView("Createing Link to Prepared")
var linkTbl = base.getTable("Prepared");
var linkView = linkTbl.getView("Prep for PD");
//Declare queries
var activeQry = await activeView.selectRecordsAsync();
var linkQry = await linkView.selectRecordsAsync();
//Loop through your active table records
for(let activeRec of activeQry.records){
//Declare field in the active table you'd like to match
let actField = activeRec.getCellValueAsString("Referenz") //If a Number, use getCellValue instead of getCellValueAsString
//Declare Variable that will represent your new value
let updRec = undefined;
//Loop through the records in the link table
for(let linkRec of linkQry.records){
//Declare field in the link table you want to match to
let linkField = linkRec.getCellValueAsString("Name") //Whether getCellValue/getCellValueAsString is used should be the same as above
//Match the records by that field
if(actField == linkField){
updRec = linkRec.id;
break;
}
}
//Update Records
if(updRec !== undefined){
await activeTbl.updateRecordAsync(activeRec, {
"Link to Prepared": [{id:updRec}] //The field type must be a linked field
});
}
}