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.

Reference Qualifier Override

scottparry
Kilo Expert

Is there an easy way to override a Reference Qualifier on a Catalog Variable?

We are using the code below to filter the reference field, but need an admin override and would rather not edit script include.

nameNOT LIKEServiceNow^ javascript: groupMembershipSelectGroupRefQual(gs.getUserID(), current.variables.name, current.variables.altname == 'add')

-Scott

1 ACCEPTED SOLUTION

Hello Cullen,



You could move the rest of the condition into the JavaScript as a string in that case:


javascript: if(!gs.hasRole('admin')) {'nameNOT LIKEServiceNow^' + groupMembershipSelectGroupRefQual(gs.getUserID(), current.variables.name, current.variables.altname == 'add')}



Please mark helpful and/or correct if you find my response as such.


View solution in original post

4 REPLIES 4

Robert Beeman
Kilo Sage

You could put an if statement in your condition like this:



if(!gs.hasRole('admin')) {     // Current user does not have Admin role


        // Your function here


}



nameNOT LIKEServiceNow^ javascript: if(!gs.hasRole('admin')) {groupMembershipSelectGroupRefQual(gs.getUserID(), current.variables.name, current.variables.altname == 'add')}


scottparry
Kilo Expert

Thanks Robert,



That works fine for the script include, but I also need the condition to be included in the override.


Hello Cullen,



You could move the rest of the condition into the JavaScript as a string in that case:


javascript: if(!gs.hasRole('admin')) {'nameNOT LIKEServiceNow^' + groupMembershipSelectGroupRefQual(gs.getUserID(), current.variables.name, current.variables.altname == 'add')}



Please mark helpful and/or correct if you find my response as such.


scottparry
Kilo Expert

I tried moving it around within the script earlier with no success, but that appears to have worked.



Thanks again Robert!