Form Builder -> UI Policy based on if the usser looking at it is part of specific group.

bigbacon
Giga Guru

Is this possible to do inside the UI policy builder from the form builder? 

I see an "End User" option but I don't know if that means what I think it means. Trying to setup a policy on a field so that it is ONLY editable if the person looking at the form is in a specific group.

4 REPLIES 4

rohansargar
Kilo Guru

Hello @bigbacon,

 

You can control field editability based on user group membership, but UI Policies by themselves don't directly support checking if a user is in a specific group via the UI Policy Builder (like a dropdown or condition builder).

 

If my response helped please mark it as correct,

Best Regards,

Rohan

Is that done through business rule?

Ankur Bawiskar
Tera Patron
Tera Patron

@bigbacon 

Sorry what's your requirement?

Are you saying a field should be readonly, editable or visible if logged in user is part of some particular group?

If yes then you can use display business rule on that table and use scratchpad variable, please enhance below

Display Business rule:

(function executeRule(current, previous /*null when async*/) {
    // Replace 'sys_id_of_group' with the actual sys_id of your target group
    g_scratchpad.isGroupMember = gs.getUser().isMemberOf('sys_id_of_group');
})(current, previous);

Client Script:

function onLoad() {
    // Check if the scratchpad variable is true
    if (g_scratchpad.isGroupMember === true) {
        // Show the field (replace 'field_name' with your field's name)
        g_form.setDisplay('field_name', true);
    } else {
        // Hide the field
        g_form.setDisplay('field_name', false);
    }
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@bigbacon 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

 

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader