Issue with Notification Time Stamp

chelsa
Kilo Explorer

Hi There,

I am fairly new to my position so I am still learning Servicenow but need some assistance.

I have a Service Catalog item variable that requests a Date and Time. In the workflow I have a Timer that is configured to wait for that time (Which is working).

Before the workflow reaches the timer, I have another sub workflow with a series of notifications set up to run. The notification refers back to the Date/Time Variable on the Catalog form.

The notification fires but the time is incorrect (5 Hours off) even when referring back to the date/time variable on the form for the time.

How do I fix this? I have confirmed the timezones are all correct in the workflows.

Here is the script I am using in the notification to call the date and time:

<table style="width:650px">

        <tr>

                <td><a href="https://xxx.service-now.com"><img src="https://xxx.service-now.com/servicedesk_logo.pngx"></img></a></td>

        </tr>

        <tr>

                <td>

                        <hr/>

                </td>

        </tr>

        <tr>

                <td>

                      <mail_script>

                              var v = current.variables;

                              template.print("Hi " + v.employee.manager.first_name +   "\n\nA termination request has been submitted for " + "(" + v.employee.name + "). " + "Please make sure you acquire all company assets from departing employee before leaving the company such as:\n1) Access cards.\n2) Laptops, PC's, and Accessories.\n3) Cell phones, Smart phones, tablets.\n4) All other misc. items such as carrying cases, headsets, cables/chargers, etc..\nLocal IT has a task to pick them up from you.\n");

                      </mail_script>

Click here to view Request: ${URI_REF}

                </td>

        </tr>

            <tr>

                    <td>

              <mail_script>

              template.print("Termination Date & Time: " + current.variable_pool.dateTime);

              </mail_script>

                    </td>

          </tr>

          <tr>

                  <td>

                      <p><br>NOTE: If this termination appears to have been submitted in error, please contact the <b>IT Service Desk</b>.</p>

                     

                      Thank you,

                     

                      Your Service Desk Team

                  </td>

          </tr>

        <tr>

                <td>

                        <hr/><p><b>NOTE:</b> Requests are processed during normal business hours (7am — 7pm M-F CT). If you have submitted this Request to report a loss or degradation of a Business Service, then please contact the Service Desk to cancel your Request and to create an Incident ticket to ensure a prompt return to service.</p>

                </td>

        </tr>

</table>

1 ACCEPTED SOLUTION

srinivasthelu
Tera Guru

5 hours is a possible difference between CT and UTC.



current.variable_pool.dateTime is printing the UTC Time. You can try current.variable_pool.dateTime.getDisplayValue() to confirm that.


View solution in original post

4 REPLIES 4

Mike Allen
Mega Sage

I believe you are dealing with time zones here.   The system is in GMT and so you are sending them GMT.   To make it in the user's timezone, you can do:



var gdt = new GlideDateTime(current.variable_pool.dateTime);


var timeZoneOffSet = gdt.getTZOffset();


gdt.setNumericValue(gdt.getNumericValue() + timeZoneOffSet);



template.print("Termination Date & Time: " + gdt);


Or



var tz = Packages.java.util.TimeZone.getTimeZone("Canada/Central");


var gdt = new GlideDateTime(current.variable_pool.dateTime);


gdt.setTZ(tz);



template.print("Termination Date & Time: " + gdt);



Something like that...


srinivasthelu
Tera Guru

5 hours is a possible difference between CT and UTC.



current.variable_pool.dateTime is printing the UTC Time. You can try current.variable_pool.dateTime.getDisplayValue() to confirm that.


i updated the script with this and then it started stamping in CDT.


THANKS!!!