Display Field Message under form field depending on Location value

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 02:55 PM
I am looking on how to best format a Client Script (I have very little code experience) to display a field message (g.form.showFieldMsg) below the Location field when the Location has a specific value in its record.
For example, in my development instance, the "Dallas" location has a field called "Time zone" and it is US/Central.
Any time a record is being created for a Location whose Time zone value is "US/Central," I'd like to display a message below the Location field in the incident form with something like "This location is in the Central time zone."

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2022 03:10 PM
Hi Edward,
You can try onChange client script on location field. Just use correct field names.
var timeZone = g_form.getValue('location.time_zone');
if(timeZone== "US/Central"){
g_form.showFieldMsg('This location is in the central time zone.');
}
Mark Correct and Helpful if it helps.
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2022 07:11 AM
Thanks!
Do you know how I can set multiple conditions other than just the one 'if'?
Like if the time zone is US/Pacific, then say "This location is in the Pacific time zone" etc.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2022 09:55 AM
Doesn't seem to work.
Here is what I have coded:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
//Type appropriate comment here, and begin script below
var timeZone = g_form.getValue('cmn_location.time_zone');
if(timeZone== "US/Central"){
g_form.showFieldMsg('This is in the Central time zone.');
}
}