Help

Save the date! Join us on October 16 for our Product Ops launch event. Register here.

Re: Inserting Today's Date and Time Using Script

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

Before starting this, I will say I have no background in writing script.  Any script/code I have posted was created using OpenAI API.

What I am trying to create is an automation that upon an update in a selected Single Select Field will begin an automation that utilizes a script to input today's date & time in an adjacent Time/Date field.

When I entered the code below into the Edit Script window and ran a test, the test failed with an error stating "

ReferenceError: document is not defined at main on line 12"
 
Can anyone provide feedback of what I need to change to make it work?
 

var today = new Date();

var options = {

  timeZone: 'America/New_York',

  hour: 'numeric',

  minute: 'numeric',

  second: 'numeric',

  hour12: true

};

var timeString = today.toLocaleString('en-US', options);

var dateString = today.toLocaleDateString('en-US');

var dateTimeString = dateString + ' ' + timeString;

var dateTime = document.createElement('div');

dateTime.innerHTML = dateTimeString;

document.body.appendChild(dateTime);

 

1 Solution

Accepted Solutions
Adam_Morrow1
4 - Data Explorer
4 - Data Explorer

Found solution with @kuovonne's automation helpers.

See Solution in Thread

1 Reply 1
Adam_Morrow1
4 - Data Explorer
4 - Data Explorer

Found solution with @kuovonne's automation helpers.