Making the worknotes mandatory when the priority changes

robinchadwick
Mega Expert

In the Incident Management application, how do I make the worknotes mandatory when the priority changes.

1 ACCEPTED SOLUTION

Swapnil Bhakar1
Mega Guru

Hi Robin,



Follow below steps to make work notes field mandatory on change of priority.



Select Table name: Your table name (e.g. Incident)


Type: onChange


Field Name:   Priority



Script:



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


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


          return;


    }




    //Clearing the value of Owner field on change of Owner Group


      if(newValue != oldValue)


    g_form.setMandatory('work_notes',true);


}



Hope this will help you.



Regards,


Swapnil



PS: Hit like, Helpful or Correct depending on the impact of the response


View solution in original post

12 REPLIES 12

Inactive_Us1474
Giga Guru

Hi Robin,



Create a client script on incident table with field as Priority.


And copy the below code:


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


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


          return;


    }


    //Type appropriate comment here, and begin script below


if(oldValue != newValue)


  {


  g_form.setMandatory('u_price',true);


  }


}




Refer : Client Scripts - ServiceNow Wiki


Thanks


Akhil


Hit Like/Helpful/Correct, if applicable.


use work_notes field name instead of u_price


Is there a way to do it without writing a script?


I guess no because firstly i thought of using ui policy but was not able to find any condition such as priority changes, then only mentioned via script.