
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-31-2023 12:28 PM
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.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 03:23 AM - edited ‎06-01-2023 03:24 AM
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" ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 04:47 AM
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" ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 04:42 AM
@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.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 04:47 AM
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" ;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2023 07:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2023 04:37 AM
@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.
ServiceNow Community Rising Star, Class of 2023