
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 10:15 AM
Hi,
I need help with client script. I have a form with one mandatory field, I need to make this field non mandatory for 3 users only. So if the login user / requester is one of A, B, C then this field should be non mandatory.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 01:35 PM
You might be having a UI policy which is setting the field mandatory .
UI policy precedence is higher than client script so its not working
if you are able to find the ui policy then remove ui action which makes the field mandatory and try with below script
function onLoad() {
var currentUser = g_user.user_id;
var nonMandatoryUsers = ['A', 'B', 'C']; // Replace A,B and C with the sys_ids of the users who should have the field as non-mandatory
if (nonMandatoryUsers.indexOf(currentUser)!=-1) {
g_form.setMandatory('field name', false); //replace field name with backend name of field to be made non-mandatory
}
else
{
g_form.setMandatory('field name', true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2023 01:35 PM
You might be having a UI policy which is setting the field mandatory .
UI policy precedence is higher than client script so its not working
if you are able to find the ui policy then remove ui action which makes the field mandatory and try with below script
function onLoad() {
var currentUser = g_user.user_id;
var nonMandatoryUsers = ['A', 'B', 'C']; // Replace A,B and C with the sys_ids of the users who should have the field as non-mandatory
if (nonMandatoryUsers.indexOf(currentUser)!=-1) {
g_form.setMandatory('field name', false); //replace field name with backend name of field to be made non-mandatory
}
else
{
g_form.setMandatory('field name', true);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 04:55 AM
Hi Manmohan,
I don't have any UI policy that setting the field mandatory . However, when I changed the "!=1" to ">0" it works. Thanks again for your help!