Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Inserting Today's Date and Time Using Script

Topic Labels: Scripting
Solved
Jump to Solution
3501 1
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.