How to show field message in Service Portal tabbed form Widget (Standard ticket configuration)

Community Alums
Not applicable

I have an OnLoad client script with UI type as All to display field message on the change form schedule tab but it works only on UI16, how can I display the same messages on the Portal form? 

function onLoad() {
var ga = new GlideAjax('GetUserInfo');
ga.addParam('sysparm_name', 'GetUserTz');
ga.getXML(GetUserInfoParse);
 
  function GetUserInfoParse(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
	g_form.showFieldMsg('start_date','Enter time based on your timezone. Your profile is currently ' + answer + ' time','info',true);
	g_form.showFieldMsg('end_date','Enter time based on your timezone. Your profile is currently ' + answer + ' time','info',true);
	g_form.showFieldMsg('work_start','Enter time based on your timezone. Your profile is currently ' + answer + ' time','info',true);
	g_form.showFieldMsg('work_end','Enter time based on your timezone. Your profile is currently ' + answer + ' time','info',true);
  }
}

 

I believe we should do something in the 'Schedule' widget server script for this to work, but not sure how. Can I get some help here please.

 

RJ8_0-1685561043499.png

 

RJ8_1-1685561043461.png

 

Thanks

2 ACCEPTED SOLUTIONS

Hello,

 

You can try adding an additional <div> in each of the <td> to show the field message. The filed message can be configured at the server end . 

 

<td>
<div class="label-column">
    <h5>Planned Start Date</h5>
 </div>
<div class="value-column bold">
      {{data.startDate}}
</div>
 <div class="wrapper-xs r m-t-xs ng-binding ng-scope bg-info">
       {{data.field_message}}
  </div>
 </td>
 

 

data.field_message can be derived from server side :

 

 

 var user_timezone = gs.getUser().getRecord().getDisplayValue('time_zone');
	data.field_message = "Enter time based on your timezone. Your profile is currently "+ user_timezone + " time" ;

 

View solution in original post

If the user has selected the default or system timezone in the profile , it returns null.

You can try changing it to some other timezone and then test it.

Moreover, you can modify the server side code to get the value of system timezone as below:

var system_time_zone = gs.getProperty('glide.sys.default.tz')
var user_timezone = gs.getUser().getRecord().getDisplayValue('time_zone');
if (!user_timezone){
data.field_message = "Enter time based on your timezone. Your profile is currently "+ system_time_zone + " time" ;
}
else 
data.field_message = "Enter time based on your timezone. Your profile is currently "+ user_timezone + " time" ;

	

View solution in original post

8 REPLIES 8

@Community Alums You can use GetUserTz function of GetUserInfo script include to get the time zone.

 

like below

 

var user_timezone = new GetUserInfo().GetUserTz();

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

If the user has selected the default or system timezone in the profile , it returns null.

You can try changing it to some other timezone and then test it.

Moreover, you can modify the server side code to get the value of system timezone as below:

var system_time_zone = gs.getProperty('glide.sys.default.tz')
var user_timezone = gs.getUser().getRecord().getDisplayValue('time_zone');
if (!user_timezone){
data.field_message = "Enter time based on your timezone. Your profile is currently "+ system_time_zone + " time" ;
}
else 
data.field_message = "Enter time based on your timezone. Your profile is currently "+ user_timezone + " time" ;

	

Community Alums
Not applicable

jaheerhattiwale
Mega Sage
Mega Sage

@Community Alums Its not working because on widget side you have added the custom code to display the dates not using the servicenow form widget.

 

Hence the suggestion given by Asif is correct to proceed with this.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023