We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

Have to add condition in reference qualifier.

MayurChaudhari
Tera Contributor

I have created this query ''javascript: if(current.variables.assign_to_self == 'Yes') new global.ITWorkRequest().assignmentGroup(current.variables.requested_for);'' in my reference qualifier for getting the groups in assignment group field. 

Now I have to add the new condition like Active is True and type is Assignment or Type is itil in it.

(Query - active=true^typeLIKEb5e83f34b50521002747c7e9bebe4b30^ORtypeLIKE1cb8ab9bff500200158bffffffffff62)

 

Now can i do that? 

 

6 REPLIES 6

Sandeep Rajput
Tera Patron

@MayurChaudhari Please try the following.

javascript: if(current.variables.assign_to_self == 'Yes') new global.ITWorkRequest().assignmentGroup(current.variables.requested_for)+'^active=true^typeLIKEb5e83f34b50521002747c7e9bebe4b30^ORtypeLIKE1cb8ab9bff500200158bffffffffff62';

Hope this helps.

 

Hello @Sandeep Rajput 

Thanks for reply but solution not working for me.

@MayurChaudhari Please share the code of 

new global.ITWorkRequest().assignmentGroup

Hi @Sandeep Rajput and @Tai Vu 

Script include I have write for it -

 

var ITWorkRequest = Class.create();
 

ITWorkRequest.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    assignmentGroup: function(userId) {
        var arryVal = [];

        var hasITILRole = this.hasITILRole(userId);

        if (hasITILRole) {

            var gr = new GlideRecord('sys_user_grmember');
            gr.addQuery('user', userId);
            gr.query();

            while (gr.next()) {
                arryVal.push(gr.group.sys_id.toString());
            }
        } else {
            var allGroups = [];
            var cr = new GlideRecord('sys_user_group');
            cr.query();

            while (cr.next()) {
                allGroups.push(cr.sys_id.toString());
            }
            arryVal = allGroups;
        }

        return 'sys_idIN' + arryVal.join(',');
    },

    hasITILRole: function(userId) {
        var gr = new GlideRecord('sys_user_has_role');
        gr.addQuery('user', userId);
        gr.addQuery('role.name', 'itil');
        gr.query();
        return gr.hasNext();
       
   

    },


    type: 'ITWorkRequest'
});