Can I set a Reference Qualifier Condition in a Catalog Client Script?

Joe Weisiger
Giga Expert

Hello,

I am creating multiple catalog items which all use a shared variable set.  I am looking for a way to set a Reference Qualifier Condition via a Catalog Client Script.  Is this possible and if so how do I code it?

Thank you,

Joe

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hey,

sorry, my bad - add after line 17 one more "}" - the entire method is not actually enclosed hence we get this error.

 

Joro

 

P.S. Sorry for the delay - my actual email is not the one pointed in my account so I dont get notifications (and I cant change it sadly)  😞

View solution in original post

16 REPLIES 16

Community Alums
Not applicable

So,

If you select from a field (as an example) "Company" Gapple, only users from this company to be selectable ?
If so use this approach :
https://community.servicenow.com/community?id=community_question&sys_id=fa338be1dbd8dbc01dcaf3231f961923

 

Will that do the trick?

 

Joro

Thanks for the help Joro. 

If I create a new script include in System UI > Script Include called "CompanyReferenceQualifier" What would the script include code look like?

Also, what would the reference qualifier look like?  I would be using a reference variable in the variable set called "employee_name"_ referencing the table sys_user > company

 

Community Alums
Not applicable

Hi Joe,

give me like 10 mins and will post here the initial version. Then we have to refine it a bit till the working thing is done 🙂

 

Joro

Thanks for the help, Joro.  I appreciate and look forward to seeing the initial version.

Community Alums
Not applicable

Sorry for being a bit late - got led astray coz of some anooying bugs popping like Covid-19 😛 So, let go then 🙂

 

var CompanyReferenceQualifier= Class.create();
CompanyReferenceQualifier.prototype = {
initialize: function() {
},

getAllowedUsers: function(user){

   var grUser = new GlideRecord('sys_user');

   grUser.addQuery('user_name', user);

   gr.User.query();

   if(grUser.next()){

     return "sys_idIN" + grUser.company + "";

},

type: 'CompanyReferenceQualifier'
};

 

 

Then we call this from the cs var set - in the advanced section add " javascript: new CompanyReferenceQualifier().getAllowedUsers(current.NAME OF THE CAT VAR)

 

Can you test it out and see whats going to blow up so we can fix it 😄