+ Start a Discussion
agabagab 

remoteFunction call on Visualforce page does not work with IE

Hello,
 
I am making a sforce.connection.remoteFunction call on a Visualforce page.  This works fine with Firefox, but with IE I get the following error: "Type mismatch".  Has anyone experienced this before?
 
Thanks,
agab-
Best Answer chosen by Admin (Salesforce Developers) 
Dogen ZenjiDogen Zenji

I completely forgot that I had this exact same problem with another client and that that client had premier support who eventually provided a fix.  Simply add the line...

sforce.connection.sessionId = "";

... anywhere in your JavaScript before you make the call to sforce.connection.remoteFunction.

Message Edited by Dogen Zenji on 10-29-2009 11:18 PM

All Answers

BobbioBobbio
I'm running into what appears to be the same problem. I'm getting a "Type mismatch" Javascript error when calling the remoteFunction method but it only happens in IE not Firefox. Did you ever figure out what the issue was? I have an open ticket with support regarding this but haven't heard back yet.
Dogen ZenjiDogen Zenji
Was support able to help you out?  I too am having this problem.
WilmerWilmer

Hi everyone,

 

I have the same problem, does any of you have the answer? 

 

My code only works for Firefox:

 

function CallWS() { var days = 0; var credit = 0; try { var myCode = '{!Custom_Object_ID}'; var envelope = '<?xml version="1.0" encoding="utf-8"?> ' + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> ' + '<soap:Body> ' + '<ValidateCredit xmlns="http://tempuri.org/"> ' + '<clientID>' + myCode + '</clientID> ' + '</ValidateCredit> ' + '</soap:Body> '+ '</soap:Envelope> '; sforce.connection.remoteFunction ( { url: "http://www.mydummyservice.com:9078/services/Service.asmx", requestHeaders: { "Content-Type": "text/xml; charset=utf-8", "SOAPAction": "http://tempuri.org/ValidateCredit" }, requestData: envelope, method: "POST", async: false, onSuccess: function(response) { days = customParseXML(response, 'Field1'); credit = customParseXML(response, 'Field2'); alert('My response: days = ' + days + '. credit = ' + credit); }, onFailure: function(response) { alert('Error response: \n\n'+response); } } ); } catch(excepcion) { alert("Catched error: \n" + excepcion + " - " + excepcion.message + "\n\n Please contact the admiinstrator."); } } function customParseXML(response, myfield) { var MyResult; if (window.DOMParser) { parser=new DOMParser(); xmlDoc=parser.parseFromString(response,"text/xml"); MyResult = xmlDoc.getElementsByTagName(myfield)[0].childNodes[0].nodeValue; } else // Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async="false"; xmlDoc.loadXML(response); MyResult = xmlDoc.getElementsByTagName(myfield)[0].childNodes[0].nodeValue; } return MyResult; }

 

This code works fine from a Javascript custom button in salesforce, but, when I added it in a Visualforce page, it only works in FireFox, not in IE.

 

I already know it is possible to call it from ApexCode, but we'd like to test this way.

 

So, does anybody have an answer to this case?

 

Regards,

 

Wilmer

 

 

 

Dogen ZenjiDogen Zenji

I completely forgot that I had this exact same problem with another client and that that client had premier support who eventually provided a fix.  Simply add the line...

sforce.connection.sessionId = "";

... anywhere in your JavaScript before you make the call to sforce.connection.remoteFunction.

Message Edited by Dogen Zenji on 10-29-2009 11:18 PM
This was selected as the best answer