addOption() in client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:50 AM
Hi all,
I have a Client Script where I am adding Choices through addOption() but when I save the record the backend value is populating instead on Label.
g_form.addOption('u_available_phone', '10', ans1[0]);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:54 AM
Hi
Please confirm you are setting the correct value also, the third parameter is the label. So are you sure ans1[0] is returning label of choice instead of value?
g_form.addOption('u_available_phone', '10', ans1[0]
);
Can you alert(ans1[0]) and see what it returns.
Regards,
Muhammad
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 04:06 AM
Also, if you can share the script include that will be helpful.
Muhammad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:56 AM
Share the whole script, its difficult to understand without the complete code
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-30-2022 02:59 AM
hi Aman please have a look at this code
Client Script -
var answ = '';
var con = g_form.getValue('parent');
var ga1 = new GlideAjax('sn_customerservice.customerPhones');
ga1.addParam('sysparm_name', 'ConsumerS');
ga1.addParam('syparm_cons', con);
ga1.getXML(HelloWorld);
function HelloWorld(response) {
answ = response.responseXML.documentElement.getAttribute("answer");
var ans1 = answ.split(",");
g_form.addOption('u_available_phone', '10', ans1[0]);
g_form.addOption('u_available_phone', '20', ans1[1]);
g_form.addOption('u_available_phone', '30', ans1[2]);
}