Best way to show/display info message / alert on form based on change of incident values? (sample script included)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 02:49 AM
Hi guys, what is the best/most effective way of displaying a message on a form to a user based on certain field values (as they change on the form).
Namely we would need a message to appear if the Customer (caller_id) was one of 25 particular customers and a certain Service and Category was selected on the incident form? In actual fact we may need to make it so it's based on a keyword being typed into the short description instead of Service/Category (e.g. 'restore'). Is this possible?
I now include an onChange (field short description) sample script which is working below but I don't think this is very effective in terms of performance currently - how can this be edited to increase incident form performance i.e. ensure it's only doing the minimum look-up necessary.
Many thanks.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var sd = g_form.getValue('short_description');
if (newValue) {
var usr = g_form.getReference('caller_id');
if (usr.u_restore_flag == 'true' && sd.indexOf('restore')!=-1) {
g_form.showFieldMsg('assigned_to',
'WARNING: This restore must be authorised before assigning for restore', false);
}
else
{
g_form.hideFieldMsg('assigned_to');
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 03:03 AM
Hi,
can you just elaborate more because what you are saying from this line In actual fact we may need to make it so it's based on a keyword being typed into the short description instead of Service/Category (e.g. 'restore') that I am not getting?
Mark correct/Helpful if it helps you.
Regards,
Apurva Malewadikar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 03:08 AM
Hi Apurva, ideally I need to know how best to display an info message / alert if someone selects a specific customer (1 of 25 users in our system) and then e.g. types 'restore' into the short description field? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2018 02:44 AM
Hi,
In this case I am not sure but may be you can use business rule by specifying these conditions and then you can use gs.addInfoMessage() to display info message.
Please mark Correct/Helpful if it helps you.
Thanks,
Apurva Malewadikar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 03:05 AM
Hi djs43,
You can use 'g_form.modified method to check for changes on the form.
http://www.servicenowguru.com/scripting/business-rules-scripting/checking-modified-fields-script/
NOTE: Mark correct or helpful if it helps you.
Warm Regards,
Raj patel