Help with dictionary override reference qualifier

Bruler1230
Tera Expert

Hello,

I need to create a dictionary override on the incident table with a reference qualifier that shows groups that are active and of a certain group type. I can do that by using type'<sysid>'^active=true

 

I also need one of the groups to only show up for users that have a certain role. How do i tie all of this together in one reference qualifier. I assume i will need a script include but need a little help.

 

Thanks!

9 REPLIES 9

its based on whether or a user has a certain role. If they have the role, the assignment group is available for selection.

cool. The script include below should get you close to what you want. If you run into any probs, let me know. 

The other post putting all the code in the ref qualifier might work too so that might be worth checking out

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

You do not have to write any script include you can achieve this completely in your reference qualifier.

 

Please use the below code. Just replace rolename, typereplacesysid and groupnamewhichdonotwantnotshow

 

javascript&colon;if(gs.getUser().hasRole('rolename')) 'typeLIKEtypereplacesysid^active=true'; else'typeLIKEtypereplacesysid^active=true^name!=groupnamewhichdonotwantnotshow';

 

Saurav11_0-1670005064022.png

 

Please mark my answer as correct based on Impact.

matthew_magee1
Giga Guru

Here's something I came up with. NOTE: have not tested.

 

here' is he script include:

matthew_magee1_0-1670006538932.png

 

Code: 

var groups = [];


function getSpecialGroups(user) {
    var check = checkUserRole(user);
    check = check.toString(); //converting response to string just in case
    var gr = new GlideRecord('sys_user_group');
    gr.addEncodedQuery('type=1cb8ab9bff500200158bffffffffff62^active=true'); //here i picked the type 'itil' and active == true
    gr.query();
    while (gr.next()) {
        groups.push(gr.sys_id.toString()); //push all the group sys_ids to the groups array. You always need to add toString when pushing to an array
    }
    if (check == 'true') { //if the use has the role, add this group sys_id
		groups.push('287ee6fea9fe198100ada7950d0b1b73');
    }
    return groups; //send the list of group sys_ids back to the dictionary override
}

function checkUserRole(user) {
    var checkRole = gs.hasRole('e098ecf6c0a80165002aaec84d906014'); //here i checked to see if the user has the role catalog
    return checkRole; //this will return 'true' or 'false'
}

 

The script above needs the user passed from the dictionary override.

 

So in the dictionary override, you'd need something like:

javascript&colon; new getSpecialGroups().getSpecialGroups(gs.getUserID())

 

Again, this is a rough cut but hopefully gets the wheels in motion. Let me know if you need some more help

matthew_magee1
Giga Guru

How's the ref qualifier going?