Hello everyone,
I'm having trouble getting this Online Customer Form code to work properly.
What this code does is to retrieve campaign information from NS, and with that informationadapt the Online Customer Form behavior to suite the corresponding campaign (redirect, submission point to both CRMs, lead source, subsidiary (..in progress)).
Everything so far is working perfectly EXCEPT the SubmitNSForm function, which won't work on some browsers.
So far it works properly on Chrome & some latest versions of FF, but it won't work on IE at all.
[LIST]
[*]On the older FF versions, firebug gives me back a "206-Partial Content" response and the lead isn't created on the system.
[*]On IE I get "JS_EXCEPTIN Error Access is Denied".[/LIST]
Does anyone have any idea where to go from here? I'm lost at the moment :h_a_w:.
//=====================================GLOBAL VARIABLES var sourcenumber = getStringVars(window.location.href)["leadsource"]; // leadsource here is the campaign code //=====================================ON INIT (getNSData) function getNSData(){ //Retrieved campaign information from the Suitelet var xmlhttp=new XMLHttpRequest(); var gnsurl = "https://forms.netsuite.com/app/site/hosting/scriptlet.nl?script=152&deploy=1&compid=xxxxxx&h=xxxxxxxxxxxxxxxxx&camid="; xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200){ var window.nsresponse = xmlhttp.responseText; } } xmlhttp.open("GET", gnsurl+sourcenumber, true); xmlhttp.send(); } //=====================================ON SAVE (OnSubmitAll) function OnSubmitAll(){ var reloadplace = getStringVars(window.nsresponse)[2]; SubmitElqForm(window.nsresponse); SubmitNSForm(); window.location.href = reloadplace; } function SubmitElqForm(e_data){ // Get the values and push them to Eloqua through the form set on the Campaign Field custevent_elqformname. var elqGetCustomerGUID = null; var elqname = getStringVars(e_data)[3]; var xmlhttp=new XMLHttpRequest(); var elqurl = "http://s2125924165.t.eloqua.com/e/f2?"; var param1 = "elqFormName="+elqname; var param2 = "elqSiteID=xxxxxxxx"; var param3 = "elqCustomerGUID="+elqGetCustomerGUID; var param4 = "elqCookieWrite=0"; var param5 = "email="+nlapiGetFieldValue('email'); var param6 = "firstname="+nlapiGetFieldValue('firstname'); var param7 = "lastname="+nlapiGetFieldValue('lastname'); var param8 = "phone="+nlapiGetFieldValue('phone'); var param9 = "leadsource="+sourcenumber; xmlhttp.open("POST", elqurl , true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.send(param1+"&"+param2+"&"+param3+"&"+param4+"&"+param5+"&"+param6+"&"+param7+"&"+param8+"&"+param9); } function SubmitNSForm(){ // Get the form values and submits them to NS. var xmlhttp=new XMLHttpRequest(); var nsurl = window.location.href; var daram1 = "email="+nlapiGetFieldValue('email'); var daram2 = "firstname="+nlapiGetFieldValue('firstname'); var daram3 = "lastname="+nlapiGetFieldValue('lastname'); var daram4 = "phone="+nlapiGetFieldValue('phone'); var daram5 = "subsidiary=2"; xmlhttp.open("POST", nsurl, true); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("User-Agent", "Mozilla/5.0"); xmlhttp.setRequestHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); xmlhttp.setRequestHeader("Accept-Encoding", "*"); xmlhttp.send("&"+daram1+"&"+daram2+"&"+daram3+"&"+daram4+"&"+daram5); } function getStringVars(n_data) { var vars = {}; var parts = n_data.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; }