
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2020 08:32 AM
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
Solved! Go to Solution.
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2020 09:12 AM
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) 😞

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2020 12:13 PM
Thank you!
I added "javascript: new CompanyReferenceQualifier().getAllowedUsers(current.employee_name)" to variable "employee_name" in the Advanced - reference qualifier in the variable set.
I created a new script include called "CompanyReferenceQualifier".
I am getting a "Parsing Error: unexpected token ," on line 18
and
"Parsing Error: unexpected token ;" on line 20
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-29-2020 09:12 AM
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) 😞
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2020 08:51 AM
Hi,
you can get the URL and determine the sys_id of the catalog item and then pass it to the GlideAjax
Then you can have dynamic reference qualifier based on the catalog item
But using Client Script you cannot set the reference qualifier
You can use advance ref qualifier and handle it in the script section there
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2020 12:24 PM
You can (at least for List type variables), but it is really a bad way of implementation for reference qualifier from performance and support side. Search for
'g_filter' +setQuery if you need that. You will get something like
window[collectorName + 'g_filter'].setQuery(filterString);
If you would like to do it on client side because of using dat from other variable field - there is no problem doing it on server side.
Most of my complex reference qualifiers looks like
javascript:new CIQualifier(current).moveEquipQualCollector();
current is your actual form that can be used on server side:
///
moveEquipQualCollector : function () {
var variables = this.currentItem.variables;
if(variables.someField1) return "myQuailifier1"
if(variables.someField2) return this.someExtraCalculation(variables.someField2)
}
this will give you: better performance, server-side logic, unit test coverage for you scripts, etc
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-28-2020 12:37 PM
Thats true Igor,
but we assume the entire g_form is not needed so we can pass the actual object of interest as param to the method. I'm aware that both ways have up and down side, but I think if using a literal prototype will only make things a bit more complicated.
I am replying here, to be honest, out of interest/curiosity - whats your use case using literall class/proto ? I know the benefits and the cost but never had a real use case on this and wanted to do it from a very long time.
Thanks in advance! 🙂
Joro