Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Display current date and time

Andre8
Giga Guru

Hello, I have a read only Date/Time field that I would like to default showing the current date and time. I have tried adding the below as the default value but doesn't seem to work:

 

javascript: new DateTime();

Andre8_0-1679519030366.png

 

3 REPLIES 3

Ashir Waheed
Kilo Sage

Hi @Andre8 

 

Follow the steps below

1. Right Click on the Date/Time Dictionary header record and select the view as Advanced.

AshirWaheed_0-1679526340187.png

 

2. In the Default Value section->checked the use dynamic default and the Value

AshirWaheed_0-1679525401490.png

3. This will resolve your issue.

 

In Case if above doesn't work you can try script as default value

javascript:new GlideDate();

 

Regards,

Ashir Waheed

Does this only work on Global tables? This isn't populating the date/time

Andre8_0-1679578839941.png

 

Yes, It does work.

You can also try the other default value I mentioned.

AshirWaheed_0-1679610937277.png

If still not seeing the date check for followings

1. Check that there is no BR, UI policy or any client script that is clearing the Value for Date/Time field.