Skip to main content
Solved

Automation - Update record, and save date field with NOW() timestamp


Karl_at_Easy_La
Forum|alt.badge.img+13

I would like to update a date field in a record, with the last time the automation executed. Is this possible in an automation, in the Update Record Action?

If you choose static, you have to enter the field manually. If you choose a dynamic value, you are only allowed to choose from an existing field or data.

 

 

Best answer by Karl_at_Easy_La

Actually I had solved this quite neatly, using a simple Javascript script. It keeps the table clean, no extra fields added, or having to use a formula field with NOW() either. I never remembered to post a reply about it.

It involves adding a 'Run a script' step, with the below simple Javascript code:

 

var dt = new Date(); output.set('nowTimestamp', dt.toISOString());

 

Then, you can use the output value 'nowTimestamp', in any value.

I hoep

I hope this helps. If anyone wants any further clarifications, ask away.

 

View original
Did this topic help you find an answer to your question?

10 replies

ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8765 replies
  • August 9, 2023

The only way to do this with Airtable’s native automations is to create a formula field in your database with the NOW() formula. Then, in your update record action, you would insert that formula field into the field that you want to update.

p.s. Note that if you have a large base, the NOW() formula can slow down a base. Other workarounds for this issue include writing your own custom JavaScript, or using Make which offers its own internal NOW function.


Forum|alt.badge.img+3
  • New Participant
  • 4 replies
  • August 9, 2023

Hi Karl,

Another workaround to Scott suggestion is instead a formula field with now formula, to create a Last Modified time field and insert the value of this field in the automation.

Kind regards, 


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8765 replies
  • August 9, 2023
cesrua1 wrote:

Hi Karl,

Another workaround to Scott suggestion is instead a formula field with now formula, to create a Last Modified time field and insert the value of this field in the automation.

Kind regards, 


Or just create a last modified time field with no automation at all! 🙂


Forum|alt.badge.img+3
  • New Participant
  • 4 replies
  • August 9, 2023
ScottWorld wrote:

Or just create a last modified time field with no automation at all! 🙂


That works if he doesn't update the record though other processes right?


ScottWorld
Forum|alt.badge.img+33
  • Brainy
  • 8765 replies
  • August 9, 2023

Yes, everything would depend on his particular workflow.


Forum|alt.badge.img+12
  • Known Participant
  • 24 replies
  • March 20, 2024

This one is still killing me years after running into a roadblock with it.  

I have an automation that triggers when certain fields are updated.  So I have a "Last Modified Time" field which is tracking those same fields.  But over the years I have modified which fields trigger the automation.. and forgotten to simultaneously change the "Last Modified Time" configuration to match... And to make it worse, one of the fields that the automation is watching is a lookup.  Which means I need three more fields to make this work: a "Last Modified Time" for the table that's being looked up, a lookup of that timestamp, and a formula field to combine the actual last modified time and the looked-up last modified time.  What a mess.

All because you can't write the current time to a record.  And because NOW() doesn't actually work.  

Sorry, I'll stop complaining now!


Forum|alt.badge.img+12
  • Known Participant
  • 24 replies
  • March 20, 2024

Actually.. thinking about it again finally prompted a better solution.

  • The automation triggers
  • Create or update a record (if this isn't naturally part of your automation, have make a dummy update)
  • Update your record with the Last Modified timestamp from the above action

In the above example, both "Update record" actions are updating the same record.  But you need to break it into two separate actions so that the second can reference the first.  

This is a much more robust solution than my previous mess, and does not rely on the dubious NOW() function. 

 


Karl_at_Easy_La
Forum|alt.badge.img+13

Actually I had solved this quite neatly, using a simple Javascript script. It keeps the table clean, no extra fields added, or having to use a formula field with NOW() either. I never remembered to post a reply about it.

It involves adding a 'Run a script' step, with the below simple Javascript code:

 

var dt = new Date(); output.set('nowTimestamp', dt.toISOString());

 

Then, you can use the output value 'nowTimestamp', in any value.

I hoep

I hope this helps. If anyone wants any further clarifications, ask away.

 


Forum|alt.badge.img+2
  • New Participant
  • 1 reply
  • November 26, 2024
Karl_at_Easy_La wrote:

Actually I had solved this quite neatly, using a simple Javascript script. It keeps the table clean, no extra fields added, or having to use a formula field with NOW() either. I never remembered to post a reply about it.

It involves adding a 'Run a script' step, with the below simple Javascript code:

 

var dt = new Date(); output.set('nowTimestamp', dt.toISOString());

 

Then, you can use the output value 'nowTimestamp', in any value.

I hoep

I hope this helps. If anyone wants any further clarifications, ask away.

 


@Karl_at_Easy_La - does the script solution slow down the Database? My use-case would require the script to run hundreds maybe thousands a day. 

Thank you


Forum|alt.badge.img+1
  • New Participant
  • 1 reply
  • February 7, 2025
Karl_at_Easy_La wrote:

Actually I had solved this quite neatly, using a simple Javascript script. It keeps the table clean, no extra fields added, or having to use a formula field with NOW() either. I never remembered to post a reply about it.

It involves adding a 'Run a script' step, with the below simple Javascript code:

 

var dt = new Date(); output.set('nowTimestamp', dt.toISOString());

 

Then, you can use the output value 'nowTimestamp', in any value.

I hoep

I hope this helps. If anyone wants any further clarifications, ask away.

 


Hello @Karl_at_Easy_La ,

Thank you for this, it is excellent and has saved me some time.

A couple of small questions on how to take this further:

1 - I need to do a similar action, where however the time stamp is 2 weeks from the date the action is carried out. Aka, when I trigger the action, I need a date to be set at 2 weeks from today, and remain statically as that date. How could the code by amended for this?

2 - I also need a similar action that only stamps the current year, how could the code by amended for this?

 

Thanks again.


Reply