How to write a reference qualifier for a Catalog Item variable?

Chaithra Srini1
Mega Expert

Hi Everyone,

I have a use case to display list of Locations in the Locations reference list based on the requested for company. I have written a script include and called it in an advanced qualifier as below, but it seems to be not working. Could anyone please provide any insights on why? 

Thank you in advance.

Below are the screenshots

find_real_file.png

 

function myScriptInclude() {
var site = ' ';
var b = gs.getUser(); //Logged-in user

var loc = new GlideRecord('cmn_location');
loc.addQuery('company',b.getCompanyID());
loc.query();

while(loc.next()) {
if (site.length > 0) {
//build a comma separated string of groups if there is more than one
site += (',' + loc.company);
}
else {
site = loc.company;
}
}
// return Groups where assigned to is in those groups we use IN for lists
return 'sys_idIN' + site;
}

 

1 ACCEPTED SOLUTION

Hi Chaithra,

the reference variable is referring to cmn_location; but the array is storing the sys_ids of the company table

you need to push sys_id of the cmn_location table i.e.

loc.sys_id.toString()

Actually there is no need of script include you can do this in advanced reference qualifier:

javascript: 'company=' + gs.getUser().getCompanyID()

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

7 REPLIES 7

Hi Chaithra,

the reference variable is referring to cmn_location; but the array is storing the sys_ids of the company table

you need to push sys_id of the cmn_location table i.e.

loc.sys_id.toString()

Actually there is no need of script include you can do this in advanced reference qualifier:

javascript: 'company=' + gs.getUser().getCompanyID()

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

I was wrong with my syntax. Thanks a lot Ankur!! 🙂 

Chaithra Srini1
Mega Expert

Thanks a lot everyone for your time and insights!!