Service Portal Ticket form show date and time wrong

jbasa
Tera Contributor

We only just caught this.

The date is the wrong format, and the time is +5 hours in 24-hour time.

Checking Sys properties, the TZ is correct for me its US/Central

The date format is set to MM/dd/yyyy

For ITIL users, in their view, Time is OK.  For Callers in Service Portal, it is 24 hour time and 5 hours ahead.

 

Based on some other posts ( in particular, this one, I did customize the ticket form widget.  However, it appears the line in question for Server Script is correct.

 

data.isNewRecord = data.sys_id == -1 || gr.isNewRecord();
data.table = gr.getRecordClassName(); // use actual table for the record
options.no_readable_journal_field_message = options.no_readable_journal_field_message || gs.getMessage("No readable comment field");
data.number = gr.getDisplayValue('number');
data.created_on = gr.getValue();

 

 

However as you can see in image the ticket created today at 2:29:04 PM translates to date and time shown

4 REPLIES 4

AnubhavRitolia
Mega Sage
Mega Sage

Hi @jbasa 

 

Have you changes the TimeZone of your user from General Setting and see if Time Changes.

 

Try to update Time Zone from Setting and see if that changes.

 

Generally such issue occurs due to different time zones selected for different users. This is expected behaviour.

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

I have, and I noticed al my users, including myself are set to the correct time zone. The image I added above is from my account and is the same as others.  

All of IT in the ITIL view see the times correctly this only the portal IT and all users see the plus 5 house and in 24 hours time even though I have it set to 12 hour

I wonder if doing the stuff described below would fix things:

- modify the Client controller around line 9-10 where right now it contains code*:

if ($scope.showDate)
		$scope.data.created_on_adjusted = dateUtils.formatDate(new Date(dateUtils.getDateFromFormat($scope.data.created_on, 'yyyy-MM-dd HH:mm:ss') + g_tz_offset), g_user_date_time_format);

that needs to be commented.

- modify the Server script by adding an additional line:

data.number = gr.getDisplayValue('number');
data.created_on = gr.getValue('sys_created_on');
data.created_on_adjusted = gr.getDisplayValue('sys_created_on');

In other words make the server fetch the date in the TZ and format selected by the current user.

 

*) Note that $scope.data.created_on_adjusted is set using slightly different code in different versions of SN, so you might not find the exact code match in your widget. The idea is to not set $scope.data.created_on_adjusted in the Client controler, but just use the value set in the Server script.

jbasa
Tera Contributor

We can close this until I have more time to review those changes in the one I created compared to the stock widget 'Ticket Conversations'.

 

I reverted back to stock and it works as it should.

 

Thanks!