Make a field mandatory in list view without using data policy

dik
Kilo Contributor

Hello All

I want make work notes field mandatory in list view when state is pending , close complete etc...   could somebody advise me how can I achieve this without using   data policy.

Thanks in advance

1 ACCEPTED SOLUTION

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Sure. Create a BEFORE Business rule with filter condition as state | Changes to | Pending,close compelte with script as


(function executeRule(current, previous /*null when async*/) {



// Add your code here


if (current.work_notes.getDisplayValue() == null) {


//do something


current.setAbortAction(true);


gs.addInfoMessage('PASS YOUR CUSTOM MESSAGE HERE');


}



})(current, previous);






View solution in original post

12 REPLIES 12

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Vibu,



You can make the field mandatory via data policy. Any reason you don't want to use this?


Hello Pradeep,



if I do it via data policy then other ways of updating state like via email or excel upload will not work.



Could you please any other way to do that


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Thanks for the update. The only option is Data policy / a BEFORE business rule on the table.


Please let me know if you have any questions.


could you please help me regarding the code