- 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:58 AM
What does the field - "id" refer??
- gr.addQuery('name',id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2017 10:08 AM
Hi,
group.type will return sys_id as this is a GlideList field. Use below script
- var gr = new GlideRecord('sys_user_group');
- gr.addQuery('name',id);
- gr.addQuery('group.type',,'sys_id of Incident group type');
- gr.query();
- if(gr.next()){
- g_form.setValue('description', 'Contains incident');
- }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-04-2017 09:51 AM
Hi,
Following can be groups types in SNOW based on my implementation experiences as ServiceNow does not provide a floating license like remedy does
- Incident Management
- Change Management
- Problem Management
- Knowledge Management
- HR Group
- Scrum Team
- Approval Groups
- Integration Groups
Group type is OOB glide list field referring to sys_user_group_type table and this means you can have multiple values in the type field.
a Sample script to query a group in a workflow attached on incident table is below
var grpType = current.assignment_group.type
if(grpType == 'sys_id') // glideList always return sys_id

- 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 10:04 AM
As Grorup Type is a Reference field, it holds a sys_ids. You need to amend your initial script as below.
- if (gr.type == 'Incident'){
to
- if (gr.type.getDisplayValue() == 'Incident'){
Hope this helps.