- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 06:07 AM
I need either a Business rule or UI policy that will allow me to cause a field to become read only unless you have a specific role. I tried using a script from SN but so far I have not gotten it to work. The script was in a business role.
functiononLoad();{
var incidentState = g_form.getValue('incident_state');
if( incidentState =='6'|| incidentState =='7'){
g_form.setReadonly('priority',true);}}
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 07:18 AM
And also for write access to a particular role. create a write acl like below:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 06:22 AM
Needed the space on the first line. Thank you for that fix. I still need to give access to edit based on role though.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 06:29 AM
Glad that helped you along 🙂
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 06:24 AM
Need a statement based around this... g_user.hasRole('role_goes_here')
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 06:32 AM
The script is also not setting the priority field to read only. Do I need to run this in something besides a business rule?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2018 06:35 AM
This should go in an Client Script...honestly...that's how I would do it. Use this as a sample:
function onLoad()
{
if(isLoading) return false;
var rqdrole = g_user.hasRole('change_unlock');
var state = g_form.getValue('State');
}
if (state == 'Scheduled' && rqdrole ){
g_form.setMandatory('start_date',false); // This makes the field non mandatory
g_form.setReadonly('start_date',false);
g_form.setMandatory('end_date',false); // This makes the field non mandatory
g_form.setReadonly('end_date',false);
}
else {
if (state == 'Scheduled')
g_form.setReadonly('start_date',true);
g_form.setReadonly('end_date',true);
}
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!