how to set a field to mandatory

mansa2
Kilo Contributor

Hi experts,

I have field in incident table called effort(u_effort)
i want to make it mandatory on condition that
if state is changed to resolved or assignment group changes.

I have written a UI policy marking when state is changed to resolved and setting the efforts feild to mandatory.
but i cant find condition like " assignment group changes" in UI policy unlike in business rules.
Can how can i achieve this.1.PNG

1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Manasa,



With mandatory fields, you typically do not make them mandatory on a change, just on a set of conditions. You don't have access to changes in a ui policy so you'd have to use a client script or multiple to accomplish that.


View solution in original post

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Manasa,



With mandatory fields, you typically do not make them mandatory on a change, just on a set of conditions. You don't have access to changes in a ui policy so you'd have to use a client script or multiple to accomplish that.


Mike Allen
Mega Sage

I agree.   To do this, you will have to put it in a client script.   I wish that the UI Policy and Data Policy condition builders had the 'changes' set of values that business rules have, but they don't right now.


Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

That is something I miss as well the "changes" option in conditions



The way I know is to make a this is either to have two onChange client scripts watching both assignment group field and state and make the field mandatory when needed. of course you can have 1 ui policy for the state is resolved and 1 onChange client script for the assignment grp changes.



Other way is make a before Business rule that checks if it is filled in otherwise set it as mandatory and cancel the submit.





//Göran


zica
Giga Guru

Laxmi,



Here is a post that display which field has been modified in the form, you can check if assignment group or state has been changed and do your logic :


http://www.servicenowguru.com/scripting/business-rules-scripting/checking-modified-fields-script/