Help with client script for incident template

sharonjanisch
Tera Contributor

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?

9 REPLIES 9

Here's the result.


find_real_file.png


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.


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');


}


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.


Here it is.


find_real_file.png