How to make OOB visible if condition is met
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2023 07:51 AM
Hi,
Im trying to make fields read only if condition is met, some of the fields that are not OOB become read only but the OOB fields dont become read only (like category,caller_id etc):
function onLoad() {
//Type appropriate comment here, and begin script below
var us = g_user.userID;
if (us != g_form.getValue('assigned_to')) {
for (var x = 0; x < g_form.elements.length; x++) {
g_form.setReadOnly(g_form.elements[x].fieldName, true);
}
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2023 07:57 AM - edited ‎09-14-2023 07:57 AM
Hi @Alon Grod,
Are the fields that aren't readonly mandatory?
If so, you cannot set mandatory fields readonly, you'll have to set them not mandatory first.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2023 10:34 AM
@Peter Bodelier still not working
function onLoad() {
//Type appropriate comment here, and begin script below
var us = g_user.userID;
if (us != g_form.getValue('assigned_to')) {
for (var x = 0; x < g_form.elements.length; x++) {
g_form.setMandatory(g_form.elements[x].fieldName, false);
g_form.setReadOnly(g_form.elements[x].fieldName, true);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2023 10:45 AM
@Alon Grod Above rational is correct that OOB mandatory field might not be becoming read only , but if the client script is still not able to make the fields read only , it seems to be overwritten by UI policy on the form
Remember UI policies execute after client scripts , so some UI policy might be overwritting it , do consider checking the ui policies and their corresponding conditions and actions
Please mark the response as helpful if it solves the issue which you are facing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-14-2023 10:49 AM
@gurjot5 does ACL override client script and ui policy?