Not able to remove choice list option from choice field.

Jonnie_
Tera Contributor

Hi

i have written a onLoad client script and on based of condition i am removing the choices from choice list field using removeOption() method. 
g_form.removeOption(‘state’, 0);

g_form.removeOption(‘state’,2);

etc. 

 

Except one, all choices(which i mentioned in client script) are gettinh removed from field on form.

but the first g_form.removeOption(‘state’,0); is still visible. I don’t know why it’s happening. I checked other UI policy and client script.

6 REPLIES 6

Pratik Malviya
Tera Guru

Hi @Jonnie_ ,

 

Did you checked default value on state field at dictionary level ?

Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Thanks,
Pratik Malviya

Basheer
Mega Sage

Hi @Jonnie_ 

There are few things which you can check to resolve this

1. Go to dictionary of that choice field and check configuration whether you've selected without None (or) With None

2. If you have selected Without None then you would have specified a default value

3. If you have specified a default value, then the field cant be removed

4. In this case what we need to do is change the configuration type to with None and try to remove the options.

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.

Jonnie_
Tera Contributor

Default value is different which is 4. I am trying to remove 0 

Do like this and debug.

open the form and select 0 as the option.

press ctrl+alt+shift+j and pop up kind will open up

type alert(g_form.getValue("column_name"));

Run it, it will give the value in alert

copy it and try to paste that in your original scirpt.

 

one more thing keep "0" and "2" instead of just 0 and 2.

 

Please hit like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

Cheers,
Mohammed Basheer Ahmed.