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

Brian Lancaster
Tera Sage

I just tried your script in my PDI and it worked fine. Have you tried putting alerts in you script so see if it is failing anywhere specific for you.

BrianLancaster_0-1744240508917.png

Also why can't you use csm_location by the way? Doing it via script means you would have to update the script every time a new location is added instead of getting it updated automatically when the location table is updated.

They don't want me to add these none Company offices to the table. Did you use the catalog client script? I can't get it to work.

 

Yes catalog client script. Is it not working in the service portal but it is working in the standard ui? This could be an issue with the UI Type field on the client script as mentioned by @Chaitanya ILCR.

 

Edit: Also why not just use the choice table in the select box instead of using a script. If you are just using a select box you should see something like this when you scroll to the bottom of the page. There you can add the choices that are selectable.

BrianLancaster_0-1744297228045.png

 

 

wyattfudal
Tera Contributor

Different offices they don't want in cmn_location table just a isolated form. I can't get it to work. Did you use a catalog client script?