isMemberof() for more than group

Shamma Negi
Kilo Sage
Kilo Sage

Hi All,

I need to use ismemberof() function for more than group.

Please suggest.

Regards,

Shamma

Regards,Shamma Negi
4 REPLIES 4

anurag92
Kilo Sage

isMember() returns a boolean value i.e true/false.



so you can use an OR to check for multiple groups. something like:



gs.getUser().isMemberOf(group1) || gs.getUser().isMemberOf(group2) || gs.getUser().isMemberOf(group3);


Chetan Sondhi
Kilo Sage

Hi Shamma,



Method "isMemberOf()" takes one GroupName/Sys_id as its argument at a time .


What you can do is to loop through an array :



var groupsArray = ['CAB Approval', 'Change Management', 'xyz'];



for(var y=0; y < groupsArray.length; y++){


  var isMember = gs.getUser().getUserByID('abc').isMemberOf(groupsArray[y]);


}



PS - Please mark Helpful, Like, or Correct Answer if applicable.



Thanks,


Chetan




Shamma Negi
Kilo Sage
Kilo Sage

Thanks Anurag and Chetan. I need to define the same in condition.



I was thinking if we can define in comma separated.



I achieved it by using OR operator.



Regards,


Shamma


Regards,Shamma Negi

zulhiyatiuwi
Tera Expert

i'm using this filter current.assignment_group.parent.name.indexOf('IT Always') > -1. and it work. Thank you for replying to my question 😄