function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GhilliGhilli 

Need help in Send to phone service of Ajax tool kit

Hi Friends,

 

I have one scenario in that i need to send the account details to the owner's mobile phone.

 

I am using the following code to do that. But while executing its asking for the user id and password.

 

If i gave that also its again loading the same the page.

 

Please help me to rectify this.

 

The code is :

 

 

 

 

 

 

<html> <head> <script type="text/javascript" src="/js/functions.js"></script> <script src="/soap/ajax/10.0/connection.js"></script> <script type="text/javascript"> function init() { alert("hi"); var carrier = "{!User.Cell_Phone_Carrier__c}"; alert("hi4"+carrier); if ( carrier == "" ) { alert( "No cell phone carrier specified" + " in your personal information"); setTimeout("window.close();",100); return; } var cell_number = "{!User.MobilePhone}"; alert("hi5"+cell_number); if ( cell_number == "" ) { alert( "No cell phone number specified"+ " in your personal information"); setTimeout("window.close();",100); return; } var l = window.location; alert("hi2"+l.href); if ( l.protocol == "https:") { l.href = l.href.replace(/https/,'http'); alert("hi3"+l.href); return; } sforce.connection.remoteFunction( {url :"http://www.google.com/sendtophone",mimeType: "text/plain",requestHeaders:{"Content-Type":"application/x-www"+ "-form-urlencoded"}, method: "POST", requestData: "gl=US&hl=en"+ "&client=navclient-ffsms"+ "&c=1&carrier="+ carrier+ "&subject={!Account.Name}"+ "&text={!Account.BillingStreet}\n"+ "{!Account.BillingCity}"+ "&mobile_user_id="+ cell_number, async: true, onFailure : done, onSuccess : done}); } function done( response ) { alert("hi6"); document.getElementById('sendtophone'). innerHTML = response; setTimeout("window.close();",5000); } </script> </head> <body onload="init();"> <div id="sendtophone" > </div> </body> </html>

 

 

 

Thanks

werewolfwerewolf

Probably because of this.  What is this about?

 

 

var l = window.location;
alert("hi2"+l.href);
if ( l.protocol == "https:") {
l.href = l.href.replace(/https/,'http');
alert("hi3"+l.href);
return;
}

 

GhilliGhilli

Hi,

 

Thanks for your immediate reply.

 

I have Put the code to replace the https to http.

 

var l = window.location;alert("hi2"+l.href);

if ( l.protocol == "https:") {

l.href = l.href.replace(/https/,'http');

alert("hi3"+l.href);

return;

}

 

The above code is not replacing the https to http.

 

Please correct me in the code to do the same. 

 

 

If i delete the above code  its saying the following message :

 

"400 Endpoint protocol(http/https) mismatch:

 

http://www.google.com/sendtophone "

 

 

 Note : I have givent the remote site setting as "http://www.google.com".

 

Thanks.

Message Edited by Ghilli on 03-18-2009 11:28 PM
GhilliGhilli
Hi Friends,

I dint fine the solution yet.
Kindly clarify this.


Thanks.
werewolfwerewolf
Try opening a new window with the URL of whatever you're calling.  You can't change the protocol of an existing window.