Populate Choice List from an Array in Catalog Task Form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 02:07 PM
Hello,
I have a "multi row variable set which" certain columns in my Catalog Item, I was able to get the values from the column named PR Number and put them in an array, the thing is that I want to add these values to a choice list field I have in my Catalog Task from.
I don't have any Script Include as I'm not familiar with that, but it seems that I need it?
This is my Client Script that applies to Catalog Tasks, and it should be added after save it or update it.
function onSubmit() {
// //Type appropriate comment here, and begin script below
if (g_form.getValue('commodity_details')) {
var jsonStr = g_form.getValue('commodity_details');
var objList = JSON.parse(jsonStr);
var part_numbers_array = [];
for (var i = 0; i < objList.length; i++) {
part_numbers_array.push(objList[i].pr_number.toString());
}
g_form.addOption('u_eu_mdr_part_numbers', 'part_numbers_array', 'EU MDR Part Numbers');
alert(part_numbers_array);
}
}
Any ideas how to achieve this? I really appreciate any help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 03:48 PM
I am not sure, why you are running an onSubmit. Do you want to run it on a change of a field value. In that case you should run it on an onChange Client script.
The script can also be improved to
if (g_form.getValue('commodity_details')) {
var jsonStr = g_form.getValue('commodity_details');
var objList = JSON.parse(jsonStr);
var part_numbers_array = [];
for (var i = 0; i < objList.length; i++) {
part_numbers_array.push(objList[i].pr_number.toString());
g_form.addOption('u_eu_mdr_part_numbers', objList[i].pr_number.toString(), objList[i].pr_number.toString());
alert(part_numbers_array);
}
}
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 06:16 PM
Hi Sanjiv,
It is not working; the dropdown is not populated with the values I need from the MRVS.
Do you think that a script include is needed?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 09:41 AM
Did you add it inside an onChange client script with field name as the commodity_details?
Please mark this response as correct or helpful if it assisted you with your question.