g_form.addOption() method creating a duplicate value after the form is saved

Kiran Pudari
Tera Contributor

Hi

I am new to serviceNow.

I am trying to add an option using g_form.addOption() method. This is adding the option. However, I have few questions related to this. Please help me to understand this concept

1. Choice added from addOption() method is not visible in sys_choice table. Is this expected behaviour ?
2. When I am trying to add an option to impact field on Incident table, it has added the choice but when the user selects the new option and tries to save it then the choice value is creating a duplicate.

1. One value is 10
2. Second Value is 10 – Super Low

May I know how to address this. Please refer to the below screenshot

Here is the ClientScript

function onLoad() {
//Type appropriate comment here, and begin script below
g_form.addOption(‘impact’, ’10’ , ’10 – Super Low’);

}

 

find_real_file.png

Thanks

Kiran

6 REPLIES 6

Harish KM
Kilo Patron
Kilo Patron

Hi I believe that is because you have 2 choice values with 10

1. 10

2. 10 - Super Low

delete the one you dont require.

 

 

Regards
Harish

Hi Harish

Thanks for your response

There is only one option I have added i.e., '10 - Super Low'. The other choice 10 is created automatically, after I select the option '10 - Super Low' in impact field on an incident and saved the form. 

Am I missing anything ?

Thanks

Kiran

 

try the below

g_form.addOption(‘impact’, ’10 – Super Low’ , ’10 – Super Low’);

Regards
Harish

Anil9866
Tera Contributor

Hi Kiran, 

I know this may be very late reply for your question, still I'll try to address the query if it is not resolved yet. 

1) May I know, how you've added these options to the dropdown [ if through script, can I have snips please]

2)As I'm recently faced, g_form.addOption is not allowing me to add duplicate values to the dropdown.

By checking the script or method that how you've configured the dropdown would be really helpful for further coordination. 

Thanks