Pass choice values from script includes and have field in catalog client script display those values in the variable on the record producer (dependency).

claudine_warren
Kilo Expert

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.

find_real_file.png

1 ACCEPTED SOLUTION

claudine_warren
Kilo Expert

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]);//

}

}


);
}

 

View solution in original post

7 REPLIES 7

claudine_warren
Kilo Expert

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]);//

}

}


);
}

 

Community Alums
Not applicable

Hi Warren,

 

In choice filed i can see both lable and value - it become duplicate entry in choice.
Is it possible add only lable in choice list.

redth
Giga Expert

Hi Claudine,

I'm working on the similar requirement and my script include is not working.

Can you please post your script include for reference or where did you use the variable name that needs to be returned to client in the script include after while loop?

Ak