- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2019 12:22 PM
I have a script include and catalog client script (below).
My alert shows a comma separated list of subcategory value, subcategory label for all the correct choices based on the dependency to category. My only issue is getting those values "into" the variable to be displayed on the record producer when the corresponding category is chosen.
Thank you in advance.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 02:15 PM
We got it done internally.
The updated Catalog Client script is below. It all works beautifully now.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
g_form.clearOptions('u_subcategory_task');
var ga = new GlideAjax('CatSubcatChoices2');
ga.addParam('sysparm_name','Choices');
ga.addParam('sysparm_cat',g_form.getValue('u_category_task'));//Tested this is correct
ga.getXML(function(response) {
var msg = response.responseXML.documentElement.getAttribute('answer').split(',');
for(var i=0;i < msg.length; i++){
g_form.addOption("u_subcategory_task", msg[i], msg[i]);//
}
}
);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2019 01:00 PM
What type of field is the variable?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2019 04:25 PM
It is a select box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 10:03 AM
Instead of g_form.addOption("u_subcategory_task", msg[i].getDisplayValue.value, msg[i].label);
have you tried msg[i].getDisplayValue('value'),
or msg[i].value
If that doesn't work you may want to try pushing to the array differently in the script include.
You could do:
subcats.push({
value: gpSub.value.toString(),
label: gpSub.label.toString()
});
then you should be able to refer to
msg[i].value and msg[i].label with no issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2019 07:28 AM
I should have mentioned in my original post, this is a scoped Application (Customer Service). So the regular method of clearing options and adding options within just a client script will not work. SN Support suggested the using of a script includes and catalog client scrip using Ajax to get this done.