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.

Limit assignment group selection based on user's group + one exception

JohnDF
Mega Sage

Hi everyone,

 

I need help with a advanced reference qualifier. 

If logged in user belong to a group which name start with "SN-CC" then he should see only his groups he belongs to + the one exception group with sys_id xyz.

 

All other logged in user which not belongs to a group which name start with "SN-CC" then he should see all assingment groups.

Thanks for help!

1 ACCEPTED SOLUTION

Hello @JohnDF ,

 

Does this resolved your issue?? If yes, Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.

 

Regards,

Siddhesh

View solution in original post

16 REPLIES 16

No idea I teset both. Script include in global and in customer Service scope. And both calls on dictionary override case table and on task global level. I dont get any gs.addinofomessage.

 

sn_customerservice.GroupFilter.filterGroups()

global.GroupFilter.filterGroups()

Hello @JohnDF ,

 

Finally I am able to identify the issue !!! See the resolution below.

 

1. First make sure the script include is accessable from 'All application Scopes'.

 

SiddheshGawade_0-1703261679294.png

 

2. See the reference qualifier syntax for sn_customerservice_cae table dictionary overide.

SiddheshGawade_1-1703261821449.png

 

 

 

Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.


Regards,

Siddhesh

 

 

 

Hello @JohnDF ,

 

Does this resolved your issue?? If yes, Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.

 

Regards,

Siddhesh

SunilKumar_P
Giga Sage

Hi @JohnDF, You can try the below script. I have tried in my PDI by replacing the sys_id with other and its working for me.

 

Script Include:

var GroupFilter = Class.create();
GroupFilter.prototype = {
    initialize: function() {},
    filterGroups: function() {
        var user = gs.getUserID();
        var groupIds = [];
        var groupFilter = '';
        var gr = new GlideRecord('sys_user_grmember');
        gr.addEncodedQuery('user=' + user + '^group.nameSTARTSWITHSN-CC');
        gr.query();
        while (gr.next()) {
            groupIds.push(gr.group.sys_id);
        }
        if (groupIds.length > 0) {
            groupFilter = 'sys_idIN' + groupIds.join(',') + ',c6c828c453751300ba3dddeeff7b1219'; // xyz is the sys_id of the exception group
            return groupFilter;
        }
    },
    type: 'GroupFilter'
};
 
Reference Qualifier: 
javascript:new global.GroupFilter().filterGroups()
 
Regards,
Sunil
 
 

JohnDF
Mega Sage

@SunilKumar_P  thanks for reply,

 

how can I test if my script include is called. I added everywhere a gs.addinfomessage but I get no message when I open a the assignmedn group on case