Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Override reference qualifier to call script include is not giving proper result

learn nv
Tera Contributor

Hi All,

I am trying to display the assignment group values based on Assignedto field value in change request. If Assigned to is empty i need to show all the available groups of type itil.

 

The issue is, I used log statements in script include and observed that script include is getting called and resulting in limited groups as expected. But, on to the change form, when i clicked on the assignment group all the groups are getting shown and no filtering is happening. Do I need to change anything while retuning the records from script include?

 

Script include:

function populateAssignmentGroup(user) {
    var groups = '';
    var finalgroups = [];  
    if (user != '') {
        var grmember = new GlideRecord('sys_user_grmember');
        grmember.addEncodedQuery('user=' + user + '^group.typeLIKE1cb8ab9bff500200158bffffffffff62^group.active=true');
        grmember.query();
        while (grmember.next()) {            
            groups = groups + grmember.group.sys_id + ',';
        }
        groups = groups.slice(0, -1);
        var grGroups = new GlideRecord('sys_user_group');        
        grGroups.addEncodedQuery('sys_idIN'+groups);
        gs.addInfoMessage('sysid: ' + groups);
        grGroups.query();
        while (grGroups.next()) {
            finalgroups.push(grGroups.sys_id);          
        }
        return finalgroups;
    } else {
        var grGroupselse = new GlideRecord('sys_user_group');
        grGroupselse.addActiveQuery();
        grGroupselse.addEncodedQuery('typeLIKE1cb8ab9bff500200158bffffffffff62');
        grGroupselse.query();
        while (grGroupselse.next()) {
            finalgroups.push(grGroupselse.sys_id);
        }      
        return finalgroups;
    }
}
 
Dictionary override:
learnnv_0-1759909728263.png

 

5 REPLIES 5

@learn nv 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader