Help with client script for incident template
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 07:18 AM
We want to have a client script that runs when our techs use a template to create an incident that will display a message when the CI field changes to a specific value.
If I select Configuration Item as the field name and use this script, it does not work:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isTemplate || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 'CI_Name')
g_form.showFieldMsg('short_description','IMPORTANT:___','info');
}
If I use select SubCategory as the field name with this script, it does work:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isTemplate || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
if (newValue == 'SubCategory_Name')
g_form.showFieldMsg('short_description','IMPORTANT:___','info');
}
Can someone tell me why this doesn't work with the CI field?
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 08:44 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 08:49 AM
Wow. Not sure how that happens. You are changing the CI field and it does that? How can isTemplate be false, then true in the same script and with one call to addInfoMessage()?
Would you mind posting the latest version of the script with the debug messages? I'm scratching my head w/o seeing this one.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 08:53 AM
Sure - this is the script as it stands now.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
g_form.addInfoMessage('Started script: isTemplate=' + isTemplate);
if (!isTemplate || newValue == '') { // Changed to bail out if NOT using a template
return;
}
g_form.addInfoMessage('newValue=' + newValue);
//Type appropriate comment here, and begin script below
if (newValue == 'd73fa4be0fdb164013ef46ace1050e65')
g_form.showFieldMsg('short_description','IMPORTANT:___','info');
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 08:57 AM
Any chance I can see a screenshot of the entire client script? I feel like there is some small detail I'm missing. The script isn't that complex.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2016 09:00 AM