URL Field Readonly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 01:37 AM
Hi,
Not able to make a particular URL type field read-only or editable based on role or group validation.
here is the script:
Business Rule (Display)
(function executeRule(current, previous /*null when async*/ ) {
g_scratchpad.userRole = gs.hasRole('xxxx');
g_scratchpad.userGroup = gs.getUser().isMemberOf('xxxx');
gs.info("Role: " + g_scratchpad.userRole);
gs.info("Group is: " + g_scratchpad.userGroup);
})(current, previous)
Client Script (onload)
function onLoad() {
var userR = g_scratchpad.userRole;
var userG = g_scratchpad.userGroup;
if (userR == 'true' || userG == 'true') {
g_form.setReadOnly('xxxx', false);
g_form.setMandatory('xxxx', true);
} else {
g_form.setReadOnly('xxxx', true);
}
}
problem: Even though the logged in user has either role or group but the URL type field is not showing as editable.
- Labels:
-
Service Desk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 01:40 AM
Why not simply create a write ACL with security attributes?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 01:44 AM
Already created that but same thing
the url type field is not editable even for validated users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 02:02 AM
Then you should check on other config.
I just created a URL field on a table and added a write acl to the field on 'itil_admin'. I am able to write to the field with an 'itil_admin' user, but not as normal 'itil' user. It works, so you must have some logic overwriting it, or your conditions aren't evaluated correctly. Use the access analyzer to see what is happening.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-07-2025 01:45 AM
Hi,
Update the client script
function onLoad() {
var userR = g_scratchpad.userRole;
var userG = g_scratchpad.userGroup;
if (userR == true || userG ==true) {
g_form.setReadOnly('xxxx', false);
g_form.setMandatory('xxxx', true);
} else {
g_form.setMandatory('xxxx', false);
g_form.setReadOnly('xxxx', true);
}
}