The CreatorCon Call for Content is officially open! Get started here.

AddOption for Dropdown field in Client script appearing as "blue" values

scocuzza
Kilo Contributor

I have a client script running on a sc_request table. 

The script will addOptions to a state field which is a dropdown based on certain conditions.

Adding the options based on the conditions work, however when they are added they appear as blue integer values once the record is saved. I add the options like so .....g_form.addOption('state', '97', 'Development Ready'); and when i select and save the record it appears as the 97 value in blue text when it should be Development Ready in just normal black text

Do i need to add these in a backend choice list / table somewhere? If I add it to the "selected" choice list then the dropdown choices are always present which i do not want as i need to add them dynamically through the client script with the addoptions. 

1 ACCEPTED SOLUTION

10 seconds to load the client script is extremely poor performance. I'd evaluate what is running on that form load that is bogging it down. Perhaps setting the client script order could also help. Here is a good article on how to evaluate what is affecting the form load:

 

Debug slow performance on the client side using Chrome

 

Unfortunately for what you are trying to accomplish I think the only way is to utilize onLoad() & removeOption().

View solution in original post

7 REPLIES 7

The purpose is to manipulate client side data. Unfortunately choice lists like this one use server side data to populate the values thus adding it through client side does not fully work. If your requirement is to only show this field sometimes can you not add it to the choice list through the selector then use removeOption() to hide it when appropriate i.e on form load? This way server side will hold the proper values for reference if it ends up getting set.

Yes I have done the removeOption way, but the client script takes about 10 seconds to load to remove the options from the dropdown and a user can go in quickly and set the dropdown to a choice that should be getting removed.

 

It was a Onload client script so im trying to convert it to perform OnChange ... 

10 seconds to load the client script is extremely poor performance. I'd evaluate what is running on that form load that is bogging it down. Perhaps setting the client script order could also help. Here is a good article on how to evaluate what is affecting the form load:

 

Debug slow performance on the client side using Chrome

 

Unfortunately for what you are trying to accomplish I think the only way is to utilize onLoad() & removeOption().