best practice to create mandatory fields is UI policy why?

sangeethasingh1
ServiceNow Employee
ServiceNow Employee

I heard that best practice to create field as mandatory is UI policy and not client script. Why is it so?

Can you please let me know performance issues if any?

Thanks

Sangeetha

15 REPLIES 15

Data policy would be one step better and generate the UI policy from that.

Deepak Ingale1
Mega Sage

Along with what Chuck has pointed out, another reason is the order of execution and control over the order of UI policies using order field.



Remember, client scripts are executed first and then the UI policies. If you have a field which is set mandatory using client script and at the same time, another UI policy making it as non mandatory, then UI policy result will be applied.


Also these conflicts are very difficult to troubleshoot.


Hi Deepak,



As I recently learned, Client Scripts now have an order field as well. It's no longer a distinguishing factor of UI Policies. I believe this came along in Fuji or Geneva. It was only pointed out to me a few weeks ago.


Hi Chuck,



This is interesting and thank you for adding a "bit" to my knowledge base.



But even if we have the "Order" field on the client script, then due to script execution engines, client scripts are always triggered first and then the UI Policies. Kindly correct me if I am wrong


Hi Deepak,



You are correct. Client scripts are still executed first (10, 20, 30, 40) and then UI policies (10, 20, 30, 40), not interleaved with each other.