Make Close notes mandatory when problem state changes to Closed/Resolved

Bruno Fernande1
Kilo Expert

Hi,

I need to make the Close notes field mandatory when a problem state changes to Closed/Resolved. I'm using this client script, but it doesn't seem to be working.

script.PNG

Here's my code

function onChange(control, oldValue, newValue) {

      if (oldValue == newValue)

              return;

      g_form.setMandatory('short_description', true);

}

1 ACCEPTED SOLUTION

Abhinay Erra
Giga Sage

You can do it using a UI policy without any code. Here is your client script code



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


if(newValue==4){


  g_form.setMandatory('field name goes here',true);


}


   


}


View solution in original post

2 REPLIES 2

Chuck Tomasi
Tera Patron

When it comes to making things mandatory, visible, or read-only based on another field value... I strongly recommend a UI policy. No scripting



This appears to be one of those cases.



http://wiki.servicenow.com/index.php?title=Creating_a_UI_Policy


Abhinay Erra
Giga Sage

You can do it using a UI policy without any code. Here is your client script code



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue === '') {


          return;


    }


if(newValue==4){


  g_form.setMandatory('field name goes here',true);


}


   


}