Make field mandatory and display an error message if not filled

GUSNOW13
Tera Contributor

Hi, I have a field called 'Request classification' on the form which should be made Mandatory. It has two options 1)Prod 2) Non prod either one of those has to be selected and by default column will have none option. If form saved without filling either of the two options it should display an error message as 'Mandatory fields are not filled' and also should n't allow the user to save the record without selecting one option. How to achieve this..

1 ACCEPTED SOLUTION

Hello,

 

If you make a field mandatory using UI policy it will not allow the user to submit form without one of the option being selected.

 

Also on portal it will show an error message as below:-

 

Saurav11_0-1669966706203.png

 

On Native UI it will show an error message as below:-

 

Saurav11_1-1669966735849.png

 

Please mark my answer as correct based on Impact

View solution in original post

7 REPLIES 7

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Please Create a UI policy on the table.

 

And add Request Classification as mandatory in the UI policy action.

 

https://developer.servicenow.com/dev.do#!/learn/courses/sandiego/app_store_learnv2_scripting_sandieg...

 

https://developer.servicenow.com/dev.do#!/learn/courses/sandiego/app_store_learnv2_scripting_sandieg...

 

Please mark my answer as correct based on Impact.

Thanks  but another requirement is ....If form saved without filling either of the two options it should display an error message as 'Mandatory fields are not filled' and also should n't allow the user to save the record without selecting one option. How to apply this

Hello,

 

If you make a field mandatory using UI policy it will not allow the user to submit form without one of the option being selected.

 

Also on portal it will show an error message as below:-

 

Saurav11_0-1669966706203.png

 

On Native UI it will show an error message as below:-

 

Saurav11_1-1669966735849.png

 

Please mark my answer as correct based on Impact

jaheerhattiwale
Mega Sage
Mega Sage

@GUSNOW13 Configure the dictionary and make the field mandatory. That will take care of all the scenarios you mentioned.

 

Right click on the field label on the form and click on 'Configure dictionary' and make the field mandatory by checking the mandatory checkbox

jaheerhattiwale_0-1669965740840.png

 

 

Please mark as correct answer if this helped you

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023