- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 09:30 AM
Hi,
I'm trying to return a list of variables to a list collector based on a selection made in a reference field to the sc_cat_item table. I.e., the requestor selects the catalogue item and the 'variables to be removed' variable only displays the variables attached to that item. See screenshot below.
I've updated the reference qualifier on the list collector to -
javascript: 'sys_idIN' + new GetCatItemDetails().getVariables(current.variables.catalogue_item_to_be_updated);
This is calling a script include function -
getVariables: function(catItem) {
var vars_array = [];
var getVars = new GlideRecord('item_option_new');
getVars.addQuery('cat_item', catItem);
getVars.query();
while (getVars.next()) {
var varsSysId = getVars.getValue('question');
vars_array.push(varsSysId);
}
return vars_array;
},
Can anyone see where I am going wrong as the variable always comes back with 'No matches found'.
Steven
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 06:45 AM - edited 03-22-2023 06:47 AM
Got it!
Please do this in reference qualifier, it will work 100%:
javascript: 'cat_item=' + current.variables.your_term_variable_name_here;
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2023 09:36 AM
Can you please try to update the Server code as:
getVariables: function(catItem) {
var vars_array = "";
var getVars = new GlideRecord('item_option_new');
getVars.addQuery('cat_item', catItem);
getVars.query();
while (getVars.next()) {
vars_array = vars_array + getVars.sys_id +",";
}
return vars_array;
},
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 02:00 AM
Hi,
Thanks for you response and assistance. Unfortunately though, the outcome is the same with no matches being returned.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 02:32 AM
Hope you are doing well!
I have checked your variable in the screenshot and I think it is single line text, you need to create the variable as mentioned below or your variable should be reference type variable and that should be referred to "item_option_new" table and you don't need to write any script include, please set the reference qualifier as mentioned in screenshot.
you can use : cat_item=current.Variables.YOUR_VARIABLE_NAME
I have tried in my PDI and it worked really well, pls check screenshot, I have tried with sys_id harcoded and it provide me the filtered data
My variable:
Response:
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 06:30 AM
Hi,
Thanks for responding again.
It works fine if I add in a hardcoded sys_id, similar to your screenshot, but when I update the reference qualifier to run against the catalogue item stored in my variable I get the same outcome as before - No matches found.
I've double checked and the variable name is correct.
cat_item=current.variables.catalogue_item_to_be_updated
Regards,
Steven