Need to check user group "Role" in UI Policy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-03-2023 06:32 AM
By using UI policy , i'm going to find the user 'group role . if the group role is itil_admin , will make the field editable for the particular user.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-10-2023 03:04 AM
That line of code is only checking if the user has the role. You also need to add some code that will be executed depending on the result of the role check. What does your complete script look like?
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-11-2023 03:15 AM
Hi,
I have tried with this code, but still it's not working. Can you suggest me in what way I can modify the code?
function onCondition() {
var isAdmin = g_user.hasRole('itil_admin','admin');
if (isAdmin) {
g_form.setReadOnly('short_description', false); // Title
g_form.setReadOnly('caller_id', false); // Client Name
g_form.setReadOnly('contact_type', false); // Channel
g_form.setReadOnly('category', false); // Category
g_form.setReadOnly('subcategory', false); // Subcategory
g_form.setReadOnly('cmdb_ci', false); // Configuration Item
g_form.setReadOnly('u_support_team', false); // Support team
g_form.setReadOnly('assignment_group', false); // Assignment Group
g_form.setReadOnly('assigned_to', false); // Assigned to
g_form.setReadOnly('activity_due', false); // Activity due
g_form.setReadOnly('close_code', false); // Close Code
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-11-2023 06:54 AM
With hasRole() method, you can only check for a single role. So you either need to call it twice:
var isAdmin = g_user.hasRole('itil_admin') || g_user.hasRole('admin');or use hasRoleFromList() method instead, which accepts multiple roles:
var isAdmin = g_user.hasRoleFromList('itil_admin','admin');
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā05-07-2023 08:18 AM
Hi Vipul Gupta,
You mentioned in the script the "admin" role, which may be working for you, but my need is the "itil_admin" role.
