Set value in client script not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2016 04:30 AM
Hi All,
I have written a client script and script include to pull bulk number of email id and setting these email ids in catalog field after submitting the form.
The email ids are coming from the script include but it is not setting into the field.
field type is Multi line Text
Client script
var product= g_form.getValue('product_line');
var ga = new GlideAjax('Test');
ga.addParam('sysparm_name','getAllContactsofAccount');
ga.addParam('sysparm_product', product);
ga.getXML(returnContact);
function returnContact(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setValue('contact_email',answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2016 06:18 AM
Hi Neethu,
Here are my thoughts:
1. What format/type is the answer value returned? Going along Anurag's line, it could be a type mismatch and it might help to modify the script include ajax to return a string value. (If it returns an array for example, a simple .toString() would not be enough).
2. As part of troubleshooting, I might also wrap the g_form.setValue in a try/catch to see if you can log an error:
try{
g_form.setValue('contact_email',answer);
} catch(err){
console.log("-=-=-=-=-=- " + err) ;
}
Also as Arnab mentioned, if you are able to log an error could you post them here?
3. Just because this is a mistake I've definitely made more than once, is the field you are trying to set on the form? Setting the field won't work otherwise.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2016 11:42 PM
It return coma separated email ids and it is coming in client script also.
The field is available on the form and it is not throwing any error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 12:25 AM
Hi Neethu
Is that contact email filed a reference filed??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 12:51 AM
No it is a multi line text field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-29-2016 01:03 AM
Can you post your script include script here too, for a better understanding?