Default value of a timestamp table field down to milliseconds

nikapikaaa
Tera Contributor

Hello, how do i set the default value of a table field to be a timestamp accurate to the millisecond? It needs to be done directly in the Dictionary entries of the Columns related list, no business rules etc.. The field is of type Long, can I keep it like that?

I tried javascript:gs.now(); but this returns only the date. 

1 REPLY 1

Chetna_dev
Kilo Sage

To set the default value of a field in ServiceNow to a timestamp accurate to the millisecond directly in the Dictionary Entries, you can use a script that gets the current timestamp in milliseconds and assigns it as the default value. Since your field is of type Long, which can hold the timestamp in milliseconds, you can keep it that way.

Here's the script you can use:

javascript : new Date().getTime()

This JavaScript expression will return the current timestamp in milliseconds when evaluated. You can set this as the default value directly in the Dictionary Entries of the field in the Columns related list.

if you find this helpful please accept as solution.

best

Chetna