Output printing as [object object] .

Deepthi13
Tera Expert

script include : i want 3 values and i am getting 3 logs , but in client script i am getting error , can someone  please suggest

find_real_file.png

client script :

 

function mycallback(answer) {
answer = JSON.parse(response.responseXML.documentElement.getAttribute("answer"));
//answer = JSON.parse(result);

var adgroup = answer.var1;
var url = answer.var2;
var orgsuffix = answer.var3;
alert('two');

g_form.setValue('ad_groupp', adgroup);
g_form.setValue('U_URL', url);
g_form.setValue('org_suffix', orgsuffix);
alert("ad grp is " + adgroup);
alert("url is " + url);
alert("os is " + orgsuffix);

}

return false;

}

17 REPLIES 17

@Ankur Bawiskar  this is working by on change, it is not woring by onsubmit.

but i have 6 variables to take in to consideration so cannot write onchange, any suggestions ?

Hi,

ideally you should not set any fields/variables using onSubmit.

you can use onChange client script for this

If my response helped please mark it correct and close the thread.

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hitoshi Ozawa
Giga Sage
Giga Sage

Can't call AjaxXML() on onSubmit(). AjaxXML() is asynchronous and onSubmit() will continue executing before Script Include returns a value.

> i have 6 variables to take in to consideration so cannot write onchange

Just do a Save on the first variable onChange() and change the variable name and right click on the header area and select "Insert and Stay" on other 5 variables.

The other choice is to check with business rule instead of using client script.