- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2017 09:00 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2017 09:57 AM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2017 09:21 AM
Hi Hugo,
For group type table is sys_user_group_type
var gr = new GlideRecord('sys_user_group_type');
gr.addQuery('name', current.type);
gr.query();
if(gr.next())
{
//write some logic
}
Hope this might be helpful.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2017 09:23 AM
Thank you for your reply.
Yes I know that is a different table, but I need to know which types a certain group contains. And if the type is not present, I need to add it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2017 09:33 AM
This will be the query you need to use.
gr.addQuery('group.type','CONTAINS',type);
Modify the code and logic. value of the "type" will be Incident/Change/Problem etc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2017 09:56 AM
I tried something like this, but it is still not doing the trick.
var gr = new GlideRecord('sys_user_group');
gr.addQuery('name',id);
gr.addQuery('group.type','CONTAINS','Incident');
gr.query();
if(gr.next()){
g_form.setValue('description', 'Contains incident');
}