how to get list of the child group of a perticular group?

devina
Kilo Contributor

Hi All

I want to find out what function is used to get all the child groups of a perticular group.   There are two fields in my table, Approval level and approval group. Both the fields are reference field refering sys_user_group. If we choose a group in approval level , then the sub group or the child group of this group should come in the approval group lookup icon.

I know this can be done with script include but in the script after query i don't know which function or condition should be used to get child group of that group. Please help if you can.

Thankyou

Devina Khare

1 ACCEPTED SOLUTION

anurag92
Kilo Sage

Unable to find any OOB Script include for this, why not use your own SI?



code would be:



var GetChildGroups = Class.create();




GetChildGroups .prototype = {


  initialize: function() {


  },


var x[];


childGroups: function(parentGroup) {


var gr=new GlideRecord(sys_user_group')


gr.addQuery('parent',parentGroup);


gr.query();


while gr.next()


{


x.add(gr.sys_id);


}


return x;


},



type: 'GetChildGroups'


}),


Let me know if this helps


View solution in original post

3 REPLIES 3

anurag92
Kilo Sage

Unable to find any OOB Script include for this, why not use your own SI?



code would be:



var GetChildGroups = Class.create();




GetChildGroups .prototype = {


  initialize: function() {


  },


var x[];


childGroups: function(parentGroup) {


var gr=new GlideRecord(sys_user_group')


gr.addQuery('parent',parentGroup);


gr.query();


while gr.next()


{


x.add(gr.sys_id);


}


return x;


},



type: 'GetChildGroups'


}),


Let me know if this helps


devina
Kilo Contributor

Thanks a lot


code is not working please send correct code