- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 02:43 AM
Hi Team ,
Am trying to make read only fields in incident for agent role users ,But I can't find any option for roles in UI policy
Please guide me
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 03:03 AM
This scenario is best handled with the help of ACLs instead of UI policy, but still if you want to make read only with script you can create a new client script "on load" on the incident table and try below mentioned script(Not tested):
if(g_user.hasRole("ROLE") ) {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 05:13 AM
I have seen you marked my answer helpful!
Please Accept the solution if it has answered your query, it would be helpful for future readers too
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 02:56 AM - edited 04-18-2023 02:58 AM
Hi,
You cannot do it by UI Policy but you can do it by onLoad client script
if(gs.hasRole('role1,role2')) {// set readonly your field}
else {// set editable your field}
but isn't it better to do this kind of things by acl. It's more suitable and ensure that users cannot edit the field in the lists
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 03:03 AM
This scenario is best handled with the help of ACLs instead of UI policy, but still if you want to make read only with script you can create a new client script "on load" on the incident table and try below mentioned script(Not tested):
if(g_user.hasRole("ROLE") ) {
var fields = g_form.getEditableFields();
for (var x = 0; x < fields.length; x++) {
g_form.setReadOnly(fields[x], true);
}
}
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 05:13 AM
I have seen you marked my answer helpful!
Please Accept the solution if it has answered your query, it would be helpful for future readers too
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2023 03:07 AM
As per best practice it should be through ACls, but if want to achieve it you can use Onload Client Script and use the below sample code :
if(g_user.hasRoleExactly('itil'))
{
g_form.setReadOnly('fieldName1', true);
g_form.setReadOnly('fieldName2', true);
g_form.setReadOnly('fieldName3', true);
}