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
OnDem DevOnDem Dev 

"Sforce not defined" javascript error alert when Custom button is clicked.

Hi,
 
From past few days, i am facing a problem when i click the custom button.
It shows a javascript error "sforce not defined".
Prior to winter'09 release, this issue was not there.
 
Is anyone else facing this issue.
 
Any help on this will be highly appreciated.
 
Thanks,
OnDemand
Best Answer chosen by Admin (Salesforce Developers) 
OnDem DevOnDem Dev

Found the solution,

 

Have to include the below script in the Custom Button Javascript code

{!requireScript("/soap/ajax/13.0/apex.js")}

 


Thanks

All Answers

RainManRainMan
What is your source code for this custom button?
OnDem DevOnDem Dev

Hi,

First line of the code in custom button javascript is

var co = sforce.apex.execute('Post','dothat',{});

And after that is the code to process the above result.

 

Thanks,

OnDemand

Doug ACFDoug ACF
We experienced a similar issue and found that we received that error when running the button in Firefox, but not in IE7.  Are you using Firefox?
OnDem DevOnDem Dev

No, i am working with IE7.

Were you able to find a solution.

Thanks,

OnDemand

OnDem DevOnDem Dev

Found the solution,

 

Have to include the below script in the Custom Button Javascript code

{!requireScript("/soap/ajax/13.0/apex.js")}

 


Thanks

This was selected as the best answer
SFDC developer55SFDC developer55

{!REQUIRESCRIPT("/soap/ajax/13.0/connection.js")}
{!requireScript("/soap/ajax/13.0/apex.js")}

 

I am using the above code but still I am getting this error..

SFDC developer55SFDC developer55

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!requireScript("/soap/ajax/29.0/apex.js")}

 

try using latest version.

 

and try to test it by deleting all the javascript and and just add the below code:

 

alert ('test1');

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
{!requireScript("/soap/ajax/29.0/apex.js")}

alert ('test2');

 

 

And on click of your javascript button, you should get these two alerts, and if there is an alert that means there is some issue in your rest of the javascript code...

 

=========

Another solution: Check under profile .. If "API Enabled" is checked or not. It should be checked.