Help

Re: Schedule Trigger / Script Action: How to add a record each day

Solved
Jump to Solution
2581 0
cancel
Showing results for 
Search instead for 
Did you mean: 
bnmry
4 - Data Explorer
4 - Data Explorer

Hi there – not new to Airtable, but new to scripting. I’d like to add a new row to a table (table:“Daily”) and set the primary field (column:“Date”) with tomorrow’s date, and run it every day. Simple, right? I suspect the best way to do this is set up a scheduled automation to, say, run each day at 7am, that creates a new row with tomorrow’s date. This would require declaring today’s date and tomorrow’s date in the correct format, either in the script or as an input config.

I’ve poured through the documentation and these boards to find a simple way to do this, but am coming up short and appealing for the first time to the pros here for a little assistance. I’ve also tried to set this up as a simpler scheduled automation using the “Create record” action, but you can’t use a formula to declare the field value, either in the automation or as a computed field (e.g. declaring “Tomorrow” as a computed field in the row)

Any advice on how to go about this seemingly simple task? Advanced appreciation for your help.

1 Solution

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

Welcome to the Airtable community!

It sounds like you want to run a scheduled automation. Note that with a scheduled automation, there is no “triggering record”, so you do not use a field value from a triggering record to get the date.

However, you can get the next trigger time from the time trigger. In your “Create record” action, pick your date field, and set it to the next trigger time from Time (from Step 1: at scheduled time).

If you want to use a script, instead of the “Create record” action, you can pass in the trigger time as an input variable, or you can have the script create a new date object with the current date/time.

See Solution in Thread

9 Replies 9

Automations can’t handle formulas directly, but you can simply create a formula field that always results in tomorrow’s date, hide that field so you don’t have to see it, and then reference that field in your automation.

The formula for this hidden field Scott mentioned could be something like:

DATEADD(CREATED_TIME(), 1, 'day')

or

DATEADD(TODAY(), 1, 'day')
kuovonne
18 - Pluto
18 - Pluto

Welcome to the Airtable community!

It sounds like you want to run a scheduled automation. Note that with a scheduled automation, there is no “triggering record”, so you do not use a field value from a triggering record to get the date.

However, you can get the next trigger time from the time trigger. In your “Create record” action, pick your date field, and set it to the next trigger time from Time (from Step 1: at scheduled time).

If you want to use a script, instead of the “Create record” action, you can pass in the trigger time as an input variable, or you can have the script create a new date object with the current date/time.

Ooh, that’s cool, @kuovonne! I never noticed those options before! Here’s a screenshot:

image

Lol. They probably didn’t exist before.

Ha! You are probably 100% correct here. This is why I really wish that Airtable would publicly give us a log of all the little changes they make to the platform. Dozens of these little changes happen every month, but they are kept secret & we can only discover them by stumbling upon them! In order to empower users of the platform, we need to be informed of all the changes & improvements. @Adam_Minich @Rose_K @Jason @Taylor_Savage

Its actually been there for months, but I do still want a change log.

bnmry
4 - Data Explorer
4 - Data Explorer

Thank you all for your replies and tips! @ScottWorld, I had originally tried to set the value of the Date field using a computed field as you suggest, but Airtable does not allow you to set a field value via automation from a computed field. Unless I’m missing something, that isn’t an option.

@kuovonne, I had seen that option as a variable, but hadn’t tried to use it in the automation directly without scripting - thank you!

edit: misread the earlier reply and think I don’t need to write the script at all. screenshot of this in action for anyone else who finds this

Screen Shot 2021-05-14 at 1.19.38 PM

This would only work if your trigger is not a time trigger, but a “Record Matches Conditions” trigger.