The Now Platform® Washington DC release is live. Watch now!
‎08-18-2010 06:36 AM
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,
‎08-18-2010 06:59 AM
hello, this might help from the SNC Guru site: http://www.servicenowguru.com/scripting/business-rules-scripting/advanced-getmygroups-function/
‎08-18-2010 07:52 AM
Thanks for your help and quick response. This helps a lot.
‎07-27-2012 09:54 AM
I have a user defined field called Division on my sys_user table, this field is just a reference field back to cmn_department.
I wanted to create a function similar to getMyGroups() & getMyAssignments() to use in filters.
This is not working for me. Here is my getMyDivision business rule:
Name = getMyDivision
table = Global[global]
Client callable = true
Active = true
Script:
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.toString(); //u_division is simply a reference field back to cmn_department
}
return MyDivision;
}
All the other examples (getMyGroups) seem to simply return an array of Strings, where each string is the sys_id. That is what I am basically doing here, but my reports don't seem to work when I use the javascript:getMyDivision()
Is something wrong with my script? I couldn't seem even find the getMyGroups function to look at that code, but did find some reference that makes me believe that is a server side function tied to the User class.
Any help is greatly appreciated!
‎07-30-2012 08:12 AM
I think you could simplify this quite a bit. Try using this as the 'getMyDivision' function.
function getMyDivision(){
return gs.getUser().getRecord().getValue('u_department');
}