CHeck if the logged in user is member of a group in Client script

Lucky1
Tera Guru

Hello all,

 

I have created a custom field on change request form, "CAB Approvers".

So, using a business rule when the state moves to Cab review, I am populating the approval groups sys_ids into that custom field.

Now, I want to check if the logged in user is member of one of those groups, in client script.

Can someone please give me script how to achieve this?

 

 

Regards,

Lucky

1 ACCEPTED SOLUTION

@Lucky1 

Please try this:

var arrGroups = current.CUSTOM_FIELD.toString().split(","); //Replace CUSTOM_FIELD with your custom field name
for (var i = 0; i < arrGroups.length; i++) {
    var group = arrGroups[i].trim();
    if (gs.getUser().isMemberOf(group)) {
        g_scratchpad.memberofcab = "true";
        return;
    }
}

If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

View solution in original post

6 REPLIES 6

@Lucky1 

Please try this:

var arrGroups = current.CUSTOM_FIELD.toString().split(","); //Replace CUSTOM_FIELD with your custom field name
for (var i = 0; i < arrGroups.length; i++) {
    var group = arrGroups[i].trim();
    if (gs.getUser().isMemberOf(group)) {
        g_scratchpad.memberofcab = "true";
        return;
    }
}

If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

Thank you Medi,

It's working.

 

 

Great!!!!!!

 

 

 

Regards,

Lucky