Issue with reference qualifier not working on platform
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
We have two list collector variables on the catalog form. We want variable 2 to display related businesses based on the value selected in variable 1. I created a Script Include to fetch the related businesses, but it is not working in the platform view. The log appears when the form is loaded, but not when the variable value changes. Could you please suggest how to fix this, and if there is another way to resolve this issue?
In this script, I am not getting value in appIds
Ref qual on variable 2:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Ramyav ,
In your case the problem is that the ref qual you wrote is not getting evaluated dynamically when the user picks a value in variable 1. That current.variables... only works properly on task forms, not on catalog item forms. That’s why your appIds is always empty in the script include.
The usual way to solve this on catalog forms is:
Script Include → make it extend AbstractAjaxProcessor so you can call it from client side.
Catalog Client Script (onChange on var1) → use GlideAjax to call that Script Include and get the list of businesses.
Set the filter/value on var2 → once you get the response, update the ref_qual of var2 (or directly set its value).
Example of the pieces:
Script Include
var TidalBusinessUtils = Class.create();
TidalBusinessUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getMyBusinesses: function() {
var appIds = this.getParameter('sysparm_appIds');
var businessIds = [];
if (!appIds) return '';
var grApp = new GlideRecord('u_cmdb_ci_svc_ba');
grApp.addQuery('sys_id', 'IN', appIds);
grApp.query();
while (grApp.next()) {
var business = grApp.getValue('u_businesses');
if (business && businessIds.indexOf(business) === -1)
businessIds.push(business);
}
return businessIds.join(',');
}
});
Catalog Client Script (onChange of var1)
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || !newValue) return;
var ga = new GlideAjax('TidalBusinessUtils');
ga.addParam('sysparm_name', 'getMyBusinesses');
ga.addParam('sysparm_appIds', newValue);
ga.getXMLAnswer(function(answer) {
if (answer) {
var filter = 'sys_idIN' + answer;
g_form.setFilter('sc_related_businesses', filter);
}
});
}
This way, when variable 1 changes, the Ajax call gets the right businesses and applies them to variable 2. The ref qual by itself won’t refresh in catalog UI, so you need the client script to trigger it.
If my answer helped you, please consider marking it as ✅ Correct and giving it a 👍 Helpful — it might help other members in the community too!
Thanks,
Astik T 😊💡
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi @Astik Thombare ,
Thanks for your response. I tried your solution, but it’s not working. I still see all businesses in the list. I also don’t think the script include is being called, because I added a log statement and don’t see it triggered when I select a value in variable 1. Do I have to add any reference qualifier on var2?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @Ramyav, If the logic is working fine when form loads, but not when the variable 1 values changes, then you might have missed to configure
ref_qual_elements=<Variable 1>
under Variable attributes. Could you please update the same for Variable 2 and try?
Regards,
Nishant