Help

Date stamp script in automations is very slow

Topic Labels: Automations
3552 10
cancel
Showing results for 
Search instead for 
Did you mean: 
Lee_Mandell
6 - Interface Innovator
6 - Interface Innovator

I’m trying to use an automation with a script to create an datestamp that be overridden. This is being used for.a microgreen farm and there are times where we will enter new plantings hours after the actually planting and the records need to be back dated. Normally just the current datestamp will work but there must be the ability of override it. I will also be doing this with a number of other values from a linked table. Here is the code for the script. There are ~7k records and the execution time if 17-18 seconds which is not acceptable. Is there anything I can do to speed this up? Hopefully I’m missing something simple.

// the table containing record links, and the linked-to table

let rootTable = base.getTable(“Planting Log”);
// the record with the links we want to summarize
// we need to create a ‘recordId’ input variable connected to a record trigger
let config = input.config();
let recordId = config.recordId;
// query the table and find our record according to its id:
let rootQuery = await rootTable.selectRecordsAsync();
let record = rootQuery.getRecord(recordId);
await rootTable.updateRecordAsync(record, {
// Change these names to fields in your base
“Date Sowed”: new Date(),
});

One thing I don’t understand is why I have to retrieve all records when I already have the id of the record I want. It seems that this could be done much more efficiently on the backend.

Lee

10 Replies 10

Hi Lee, I agree about field bloat (what I call it). In this example, I look at adding “Created Time” as a way to expose a property of the record object that is otherwise inaccessible. Would be nice to just have it available in the automation (or script - I have no idea if it already is) without adding the field.