- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2024 06:09 PM
Hi All,
I have a requirement to filter Assignment group but ONLY if the type is Normal. I know how to use the simple and advanced. I have not done this using Dynamic which I think is what I need (please let me know if this is not correct).
So I want to return only 4 groups if the type is Normal. If it's any other type, I do not want to filter the groups. Is there a quick way to say
if (type == "normal"){
var mygrps= [];
var gr= new GlideRecord('sys_user_group');
gr.addQuery('cm', true);
gr.query();
while(gr.next()) {
mygrps.push(gr.sys_id);
}
return mygrps;
}else{
// do nothing? I would like to see all the groups if it's not normal type
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2024 07:54 PM
Hi @MWright1 ,
Just create one script include and pass the value of assignment group type through reference qualifier.
- Assignment group reference qualifier:
- javascript:new TestingReference.().getInfo(current.assignment_group.type);//on the table side if you are on catalog sidethen use: javascript:new TestingReference.().getInfo(current.variables.assignment_group_variable_name.type);
- Use below script inlcude
- var TestingReference = Class.create();TestingReference.prototype = Object.extendsObject(AbstractAjaxProcessor, {getInfo: function(type) {var list=[];if(type=='2e763549d7111100828320300e61038d')//pass the sys_id of group type normal{var gr=new GlideRecord('sys_user_group');gr.addQuery('type',type);gr.query();while(gr.next()){list.push(gr.getValue('sys_id'));}return 'sys_idIN'+list;}else// it will return all the list of group including normal type as well{var gr=new GlideRecord('sys_user_group');gr.addQuery('active',true);gr.query();while(gr.next()){list.push(gr.getValue('sys_id'));}return 'sys_idIN'+list;}},type: 'TestingReference'});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2024 06:56 PM - edited 04-28-2024 06:56 PM
Hi @MWright1
where did you written this reference qualifier?
If you are writting on the table then you must have to use
current.type
If it is on catalog then you need to use
current.variables.type
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2024 07:03 PM
Hi @MWright1 ,
Please update your code with below code
var mygrps= [];
var gr= new GlideRecord('sys_user_group');
gr.addQuery('active', true);
gr.query();
while(gr.next()) {
mygrps.push(gr.sys_id.toString());
}
return mygrps;
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-28-2024 07:54 PM
Hi @MWright1 ,
Just create one script include and pass the value of assignment group type through reference qualifier.
- Assignment group reference qualifier:
- javascript:new TestingReference.().getInfo(current.assignment_group.type);//on the table side if you are on catalog sidethen use: javascript:new TestingReference.().getInfo(current.variables.assignment_group_variable_name.type);
- Use below script inlcude
- var TestingReference = Class.create();TestingReference.prototype = Object.extendsObject(AbstractAjaxProcessor, {getInfo: function(type) {var list=[];if(type=='2e763549d7111100828320300e61038d')//pass the sys_id of group type normal{var gr=new GlideRecord('sys_user_group');gr.addQuery('type',type);gr.query();while(gr.next()){list.push(gr.getValue('sys_id'));}return 'sys_idIN'+list;}else// it will return all the list of group including normal type as well{var gr=new GlideRecord('sys_user_group');gr.addQuery('active',true);gr.query();while(gr.next()){list.push(gr.getValue('sys_id'));}return 'sys_idIN'+list;}},type: 'TestingReference'});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2024 10:55 AM
I don't think we need to write the else condition because we have to filter the groups only if the type is normal else no need to perform any action(which means the filter doesn't apply and it will return all the records)
Murthy