Changing or Creating a new getMyGroups() function

HunterSWolf
Giga Guru

I was curious to see if anyone had created a new getMyGroups() function and if so how they did so. We are running into issues where we want to get a users groups but we do not want to pull back the parent groups. With the current function it will pull back all of these group. Looking at the business rule where this function resides it would appear that it is calling itself so I can only imagine that it is hard coded.

Thanks,

8 REPLIES 8

thank you for the solution and also sharing about using a script include VS using a global business rule!


pdavidson
Giga Contributor

i am looking for something similar, but want create a new business rule called getMyDivision. It is not working for me


HunterSWolf
Giga Guru

Have you tried returning this as an array rather than the string value?




function getMyDivision(){

var MyDivision;
var uID = gs.getUserID();

var user = new GlideRecord('sys_user');
user.addQuery('user', uID);
user.query();

while(user.next()){
MyDivision = user.u_division.split(','); //u_division is simply a reference field back to cmn_department
}

return MyDivision;
}


Yes, I have tried returning an array of Strings also, this does not work either.


function getMyDivision(){

var DivisionArray = new Array();

var uID = gs.getUserID();
var user = new GlideRecord('sys_user');
user.addQuery('user', uID);
user.query();

while(user.next()){ DivisionArray.push(user.u_division.toString()); }

return DivisionArray;
}


I have also tried returning a "cmn_deparment" variable instead of a String, since that is the reference field's table. This did also not work