Check group type of a group

hugogomes
Giga Expert

Hi everyone,

I'm developing a catalog item, to create and modify groups.

My issue is to add or check the group type (incident, request, change, problem)

Is there a way to check, through client script if a certain group contains group types? Also, I will need to add the group type, in a workflow run script.

I tried to do something like this:

var gr = new GlideRecord('sys_user_group');

gr.addQuery('name',id);

gr.Quey();

while(gr.next()){

if (gr.type == 'Incident'){

g_form.setValue('incident_process',true);

}

}

I'm kind of confused with this.

Any help?

Thank you

1 ACCEPTED SOLUTION

vinothkumar
Tera Guru

Hi Hugo,



Instead of incident, you have to pass the sys_id, since it is a glide list, it will contains the sys_id rather than display value.



var gr = new GlideRecord('sys_user_group');  


gr.addQuery('name',id);  


gr.Quey();  


while(gr.next()){  


if (gr.type == 'sys_id'){     //Pass the sys_id of the record referred here[sys_user_group_type] .


g_form.setValue('incident_process',true);  


}  


}  


View solution in original post

11 REPLIES 11

Arnab Karak
Giga Expert
  1. var gr = new GlideRecord('sys_user_group');  
  2. gr.addQuery('group.type','CONTAINS','Incident');
  3. gr.Query();  
  4. while(gr.next()){  
  5. g_form.setValue('incident_process',true);  
  6. }


Try this one. And let me know.


Rashmi Bansal
Mega Guru

Hi Hugo,



Please try below code.



var gr = new GlideRecord('sys_user_group');


gr.addEncodedQuery('name=Insert name of group here^type=sys id of the group type here');


gr.Quey();


if(gr.next()){


g_form.setValue('incident_process',true);


}