Need to check user group "Role" in UI Policy

subashds6515
Tera Contributor

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.

23 REPLIES 23

@subashds6515  - please change line 2 in your UI policy script, it should be

var isAdmin = g_user.hasRoles('itil_admin','admin');

 

If my answer has helped with your question please mark it as correct and helpful.

 

Thanks!

I am also try this way, but its not working.

 

 

function onCondition() {

    var isAdmin = g_user.hasRoles('admin');

    if (isAdmin) {

        g_form.setReadOnly('short_description', false); // Title

    }

}

UI Action when to apply.JPGUI Action script update.JPGUI Policy Action update.JPG

Slava Savitsky
Giga Sage

To make a field read-only or editable based on user roles or group membership, use an ACL and not a UI Policy.

Vipul Gupta1
Tera Expert

When a user is added to a group, the user is also assigned with a role that are assigned to a group. you can do below. please mark it helpful if you find it helpful.

 

1 Navigate to "UI Policies" under "System UI" in the left-hand navigation pane.
2 Click the "New" button to create a new UI policy.
3 Give the UI policy a name such as "ITIL Admin Edit Field."
4 In the "Advanced" tab, set the "Table" field to the table that contains the field you want to make editable.
• In the "Conditions" tab, add a new condition with the following settings:
• Type: Script
• Condition: gs.hasRole('itil_admin')
• In the "Actions" tab, add a new action with the following settings:
• Type: Set Field Value
• Field: [Name of the field you want to make editable]
• Value: true
• Mandatory: Check the box to ensure that the field must be filled before the record can be saved.
5 Save the UI policy.