
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 09, 2020 07:54 AM
I know about the restriction related with max CPU time (“Scripts can use a maximum of 1 second of CPU time”). I created a script that runs into automation section, in 95% of times, it runs using less than 500 miliseconds of CPU time but sometimes it exceeds the 1000 miliseconds.
I dont think so but I need try: there is an way (even paying more) to get more time?
If it is not possible, what is the best approach to try reduce the time? I mean, what is the part of the code that are “more CPU time consuming” for Airtable perpective?
let users = base.getTable('CoreVette');
let reps = base.getTable('Reps');
let refs = base.getTable('References');
let inputConfig = input.config();
let newRecordId = inputConfig["recordId"];
let repsResult = await reps.selectRecordsAsync();
let repsStorage = {};
for (let recordRep of repsResult.records) {
repsStorage[recordRep.getCellValue('Email')] = recordRep.getCellValue('Manufacturer');
}
let refsResult = await refs.selectRecordsAsync();
let refsStorage = {},
ptAux = '',
refAux = '';
for (let recordRef of refsResult.records) {
ptAux = recordRef.getCellValue('PT VALUE');
if (ptAux == null) {
ptAux = '';
}
refAux = recordRef.getCellValue('LIST OR TYPE');
if (refAux == null) {
refAux = '';
}
refsStorage[recordRef.getCellValue('DOMAIN')] = {
'point': ptAux,
'reference': refAux
};
}
let result = await users.selectRecordsAsync();
let flagUpdate = false,
objectToUpdate = {},
domain = '',
email = '',
manufacturer = '',
refValue = '',
pointValue = '';
for (let record of result.records) {
if (record.id == newRecordId && record.getCellValue('Email')) {
domain = record.getCellValue('Domain');
email = record.getCellValue('Email');
flagUpdate = false;
objectToUpdate = {};
if (typeof repsStorage[email] != "undefined") {
manufacturer = repsStorage[email];
if (typeof manufacturer != "undefined") {
objectToUpdate['Rep Mfr'] = manufacturer;
flagUpdate = true;
}
}
if (typeof refsStorage[domain] != "undefined" && refsStorage[domain]) {
refValue = refsStorage[domain]['reference'];
pointValue = refsStorage[domain]['point'];
if (typeof refValue != "undefined") {
objectToUpdate['References'] = refValue;
flagUpdate = true;
}
if (typeof pointValue != "undefined") {
objectToUpdate['Point Value'] = pointValue;
flagUpdate = true;
}
}
if (flagUpdate) {
await users.updateRecordAsync(record, objectToUpdate);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sep 09, 2020 08:05 AM
I answered this in your other post on the same topic.
