Reference Qualifier

MWright1
Giga Guru

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

}

 

1 ACCEPTED SOLUTION

Seraj
Tera Guru

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'
    });

View solution in original post

6 REPLIES 6

Murthy Ch
Giga Sage

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

 

 

Thanks,
Murthy

Community Alums
Not applicable

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 

Seraj
Tera Guru

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'
    });

@Seraj 

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)

 

Thanks,
Murthy