Email body time zone doesn't match local time zone

Abbottronix
Tera Guru

We have a couple of email notifications that need to use email scripts to populate the body of the email, and the email bodies include the opened and closed times of tickets. However, when we use the email scripts to show these variables, the time zone is incorrect. For example, if a request is opened at 3:05pm, the email will say it was opened 10 hours earlier at 5:05am. The time is displayed correctly everywhere else in our ServiceNow instance. If we don't use an email script to show the variables and instead select the field values in the notification editor, the correct time zone is shown. Unfortunately, not using an email script isn't an option in this scenario. 

 

The email script code we're using:

Abbottronix_3-1722319398121.png

 

Time displayed when we use an email script:

Abbottronix_0-1722318216216.png

 

How the field value looks when it's populated in the notification text editor:

Abbottronix_2-1722319261265.png

 

Time displayed when we select the field values in the notification text editor:

Abbottronix_4-1722319583855.png

 

1 ACCEPTED SOLUTION

SN_Learn
Kilo Patron
Kilo Patron

Hi @Abbottronix ,

 

Could you please try with below in notification email script:

current.opened_at.getDisplayValue()

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

2 REPLIES 2

SN_Learn
Kilo Patron
Kilo Patron

Hi @Abbottronix ,

 

Could you please try with below in notification email script:

current.opened_at.getDisplayValue()

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

Amit Verma
Kilo Patron
Kilo Patron

Hi @Abbottronix 

 

The values are stored in GMT. But when it is displayed on form/list it displays in user timezone. When you do current.opened_at, you are getting GMT time. To get the actual display value, use the below line of code :

 

current.opened_at.getDisplayValue()

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.