Script Includes to Check Groups the User is in and for Custom Group Field

Community Alums
Not applicable

I was wondering if someone could help me with a script includes that checks the groups the user is in and if the group has a custom field called u_allow_all (true/false) checked. It would pass in the current user, check what groups they're in, check if any of the groups have the u_allow_all flag checked and return true, otherwise return false.

Thanks,

Aryanos

3 REPLIES 3

David OBrien
Kilo Guru

You should be able to use something like this in your script include to query the group membership table and check the 'Allow All' attribute from the group.   Not sure where you want to call this from but I was just trying it from a background script and passing it gs.getUserID().  



function checkGroups(usr){


  var grMember = new GlideRecord('sys_user_grmember');


  grMember.addQuery('user',usr);


  grMember.query();


  while (grMember.next()){


  if (grMember.group.u_allow_all)


  return true;


  }


  return false;


}



Hope that helps.


Community Alums
Not applicable

Thanks David, I'm planning to call it in an ACL so hopefully that won't be an issue. I'll test it out and let you know how it goes.



Aryanos


Yes, it should work from an ACL script.