Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need to make field mandatory before state close/complete

Gillerla Rajesh
Tera Contributor

I need to make field mandatory before state close or complete using ui policy i made state is closed by I need before close how can I achive

10 REPLIES 10

Tushar
Kilo Sage
Kilo Sage

Hi @Gillerla Rajesh 

 

can you please try below code -

 

Condition -

current.state == 'Closed'

Script:

if (current.getValue('field_name') == '') {
  gs.addErrorMessage('The field_name field is required.');
  current.setAbortAction(true);
  return;
}

 

Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!

Regards,
Tushar

Here where can I make filed mandatory directly abort condition

Danish Bhairag2
Tera Sage

Hi @Gillerla Rajesh ,

 

I am not sure if I understood your question correctly , but while submitting whenever the state is closed completed u need to check if certain fields are filled or not, Make them mandatory if not.

 

For above u can create a OnSubmit script in which u can start with a condiiton if state is closed complete then check whether field is filled or not if empty make that  field mandatory & return false.

 

Or u can make a particular field mandatory by creating UI policy with condition as State is in progress(just an example)

 

Thanks,

Danish

 

Vishal Birajdar
Giga Sage

Hi @Gillerla Rajesh 

 

Can you share some screenshot of your UI policy & policy action please...!!!

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates