Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?

Karunakar3
Kilo Contributor

Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?

1 ACCEPTED SOLUTION

Josh Virelli
Tera Guru

Hi Karunakar,

You can of course set a field to both Read-Only and Mandatory, however the Read-Only part will "win-out" against it. Meaning, even if there isn't a value in the field, you could still save the record. Just like Mandatory will win out over Visible.

I would rarely recommend using the checkboxes on the Dictionary Entry to set Read-Only and Mandatory, instead I'd recommend using a UI Policy.

I think there are very few use cases for making something Read-Only and Mandatory. One I can think of is if you want to ensure a field is always Mandatory, and there are cases that would change whether or not it is Read Only, but even then, I would think you could have the Mandatory set to true/false with the opposite of the same condition as the Read Only being set to true/false.

Is there a specific use-case you had in mind, or did you just want some thoughts on this? Let me know if I can assist further. 

If my answer was helpful or answered your question, please mark it as 'Helpful' or 'Correct'

Thanks!

Josh

View solution in original post

10 REPLIES 10

That works!! I had used the 'else' but my braces were set differently.

 

Thank you!!

That works!

Another angle I was presented with was by default, users all having role 'test_read_only', and instead of the role being removed, adding the role 'test_mandatory' for specific users.

Would that even be possible?

Just tested by setting a field Read-only and mandatory using UI policy. The result is the field is made mandatory and a value needs to be entered (that is, it's not read-only).

UI Policy

find_real_file.png

 

Try it page

find_real_file.png

Submit without entering value

find_real_file.png

Hi Josh, I had a interview question. Can u solve it for me?.

I can make a field as Mandatory, read-only and visible using Dictionary Override and as well as UI Policy. Which one would u chose?

AbhishekGardade
Giga Sage

Hello Karunakar,

Client Script:

Client scripts allow the system to run JavaScript on the client (web browser) when client-based events occur, such as when a form loads, after form submission, or when a field changes value.

Use client scripts to configure forms, form fields, and field values while the user is using the form. Client scripts can:
  • make fields hidden or visible
  • make fields read only or writable
  • make fields optional or mandatory based on the user's role
  • set the value in one field based on the value in other fields
  • modify the options in a choice list based on a user's role
  • display messages based on a value in a field

UI POLICIES:

UI policies dynamically change the behavior of information on a form and control custom process flows for tasks.

For example, you can use UI policies to make the number field on a form read-only, make the short description field mandatory, and hide other fields. Basic UI policies do not require any scripting, however for more advanced actions, use the Run scriptsoption.

You can also use client scripts to perform all of these actions, but for faster load times use UI policies when possible

Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade

 

Thank you,
Abhishek Gardade