A reference field, that must be "required/mandatory" & read only at the same time

HenryD
Tera Guru

Hello, I have a reference field that is "read only" right now, it gets its value from a client script that is dependent on another field, I need to have this read only field also "mandatory". I tried a simple UI policy to put the field mandatory but now the field can be accessed and is not read only. 

 

Anyone know how to make a field read only and mandatory at the same time.

TYA

4 REPLIES 4

Mark Roethof
Tera Patron
Tera Patron

Hi there,

 

Basically a field cannot be mandatory and read-only.

 

What is it that you are after? For example that if the read-only field is not populated, that the user cant insert/update the record? If so, you could for example go for onSubmit Client Script checking this.

 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hello, yes actually the onsubmit script is basically what im trying to get filled in, how can i make that happen? so basically that field news a value to submit thru a OnSubmit script

Satishkumar B
Giga Sage
Giga Sage

Hi @HenryD 

You can indeed set a field to both Read-Only and Mandatory, but in practice, the Read-Only setting will override the Mandatory requirement. This means that even if the field is empty, you can still save the record. Similarly, the Mandatory setting will take precedence over Visibility settings.

I generally advise against using the checkboxes in the Dictionary Entry to set a field as Read-Only and Mandatory. Instead, I recommend using a UI Policy.

There are very few scenarios where you would need a field to be both Read-Only and Mandatory. One example might be if you want the field to always be Mandatory, with conditions that occasionally make it Read-Only. Even in this case, you could set the Mandatory property to true/false using the opposite condition to the Read-Only setting.

Is there a specific use case you have in mind, or were you just looking for some insights on this? Let me know if you need further assistance.

……………………………………………………………………………………………………

Please Mark it helpful 👍and Accept Solution✔️!! If this helps you to understand. 

AndersBGS
Tera Patron
Tera Patron

Hi @HenryD ,

 

Why would you have a field both read only and mandatory? If the field is read only and mandatory at the same time, and if the script doesn't field the field utilized by the client script, then the user is stuck.

 

You should instead leave the field as read only and make the dependent field mandatory. By doing this you will obtain the same. 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

Best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/