Schedule Job "run as"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2018 01:39 AM
Hi
I have a scheduled job which triggers an event to run a notification email script.
It shows the last 24hrs worth of incidents and must show the start time in the users time zone. When i click the "preview notification" button in Notifictions the time is shown correctly as the users time zone:
However, when the schedule is triggered the email comes out showing the system time:
It doesn't seem to make any difference if i change the "run as" user in the scheduled job, it still sends the email out using the system time.
My code is obviously working because it shows correctly in the "preview notification" so there must be something im doing wrong with the scheduled job? Can anyone shed light on this?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2018 01:56 AM
Hi Russell,
You must have written email script to get the date/time value.
Can you share the code?
if you have written something like this:
current.<dateTimeField> then it would show in email body as the GMT time.
If you use current.<dateTimeField>.getDisplayValue() it will show the value in that user's time zone which is running this script.
Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2018 02:06 AM
Like i say, i dont think it has anything to do with my code as it displays the correct time zone when i "preview notification" but here is the section of code which displays the time:
while (gr.next()) {
var ct = gr.getDisplayValue('u_begin');
template.print(" \
<tr> \
<td style='width: 84.65pt; border: 1pt solid; padding: 0cm 5.4pt; vertical-align:top;'> \
<p> \
<span style='font-size:10.0pt;'>"
+ ct
Its only when the code is ran by the schedule when it displays the system time instead
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2018 02:24 AM
Hi Russell,
What happens when any user received the email notification?
Does it show the time as shown in the Run as user's timezone or does it show in GMT?
Can you check what is the value of Run as Tz in that schedule job.
In which timezone you want the value to be displayed in email notification.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-25-2018 02:54 AM
No matter who I put in the "run as" field in the schedule it always shows the time in GMT in the email. I have tested with users in different time zones and the email always displays GMT.
I have changed the "run as tz" to "US/Eastern" but the time in the email still shows the system time GMT.