- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2019 03:01 AM
Is it possible to make a field mandatory and read only in the form ? If yes what is the use ?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2019 02:09 PM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2019 02:09 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2019 11:44 PM
Hi Josh,
Thanks for the quick reply, I need some scenarios where will we use mandatory and read only for a field in the form ??
Thanks in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2020 06:30 AM
Hi
I've started with this:
function onCondition() {
if(g_user.hasRoleExactly('test_read_only'))
g_form.setMandatory('name', false);
g_form.setReadOnly('name', true);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-30-2020 07:24 AM
Hey Mairvette,
If I'm understanding correctly, I think you would just add an Else If condition for that second role
function onCondition() {
if(g_user.hasRoleExactly('test_read_only')){
g_form.setMandatory('name', false);
g_form.setReadOnly('name', true);
}else if (g_user.hasRoleExactly('test_mandatory'){
g_form.setMandatory('name', true);
g_form.setReadOnly('name', false);
}
}
Let me know if that helps!
If my answer was helpful or answered your question, please mark it as 'Helpful' or 'Correct'
Thanks!
Josh