How can add Java Script Add option via catalog client Script the variable is Select Box

wyattfudal
Tera Contributor

I cannot use the cmn_location table so the Select Box was an option. I need to add options to search dynamically. I tried to do this script. The script is not working for me

function onLoad() {

 var fieldname = "please_select_your_professional_service_line_reporting_office_name";

 g_form.clearOptions(fieldname);

 g_form.addOption(fieldname, '', '-- Select a Location --');

 var locations = [

'Mt Doom',

'Middle Earth',

 ];

locations.forEach(function(location)

{

    g_form.addOption(fieldname, location, location);

});

}

wyattfudal_0-1744234867620.png

 

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @wyattfudal ,

your script don't have any issues.

check if the UI type of the client is set to ALL or not if not change it to All and try

ChaitanyaILCR_0-1744249988414.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

6 REPLIES 6

Chaitanya ILCR
Kilo Patron

Hi @wyattfudal ,

your script don't have any issues.

check if the UI type of the client is set to ALL or not if not change it to All and try

ChaitanyaILCR_0-1744249988414.png

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Ankur Bawiskar
Tera Patron
Tera Patron

@wyattfudal 

your script should work fine provided your choice value and choice label are both "Mt Doom" and "Middle Earth"

share your choices screenshots

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader