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

Asif Khan M
Giga Guru

Can you also paste the code written inside 'Schedule' widget?

Community Alums
Not applicable

Hi @Asif Khan M 
Below is the HTML code

<div>
  <div class="overview">
  	<div class="panel panel-{{::c.options.color}} b">
 
  	  <div class="panel-body"> 
        <table class="info-table"> 
          <tbody class="tbody-class">
           <tr>
             <td>
               <div class="label-column">
                 <h5>Planned Start Date</h5>
               </div>
               <div class="value-column bold">
                 {{data.startDate}}
               </div>
             </td>
             <td>
               <div class="label-column">
                 <h5>Planned End Date</h5>
               </div>
               <div class="value-column bold">
                 {{data.endDate}}
               </div>
             </td>  
             </tr>
            <tr>
             <td>
               <div class="label-column">
                 <h5>Work Start</h5>
               </div>
               <div class="value-column bold">
                 {{data.workStart}}
               </div>
             </td>
            
              <td>
                <div class="label-column">
                  <h5>Work End</h5>
                </div>
                <div class="value-column bold">
                  {{data.workEnd}}
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </div>

  </div>
</div>

 Server Script as follows

(function() {
    var gr = $sp.getRecord();  
	
		data.startDate = gr.getDisplayValue('start_date');
		data.endDate = gr.getDisplayValue('end_date');
		data.workStart = gr.getDisplayValue('work_start');
		data.workEnd = gr.getDisplayValue('work_end');
})();

 

Thanks

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" ;

 

Community Alums
Not applicable

Hi @Asif Khan M , Thanks for the response.

 

It has partially worked, not fetching the user time zone yet.

RJ8_0-1685618945148.png

Thanks