You need to sign in to do that
Don't have an account?

Problem in invoking Apex code using custom button(Executing java script) on Search Layout(List View)
Hi,
I am invoking apex code and I am using AJEX toolkit to do so.
http://salesforcesource.blogspot.com/2009/06/triggering-apex-method-with-custom.html
If I am usingfollwing libraries with version 10.0 like:
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
all works fine.
But if I change version 10.0 to higher like:
{!REQUIRESCRIPT("/soap/ajax/22.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js")}, it doesn't work.
Can anybody help ??
Could you explain your problem in detail?
What is the error?
Case 1: I want to execute an Apex method by using Custom button. Button is placed on Search Layout(List View) section of Lead Object as it is a List button and its behaviour is execute java script.
For invoking apex method, I am using AJAX toolkit, code is written same as below:
{!REQUIRESCRIPT("/soap/ajax/22.0/connnection.js")}
{!REQUIRESCRIPT("/soap/ajax/22.0/apex.js")}
sforce.apex.execute("classA","MethodA", {});
alert("execution started." );
But when I click on Leads tab, page reloads. Button doesn't work and at error console an error message shows:
"userContext not defined."
Case 2: When I use following code:
{!REQUIRESCRIPT("/soap/ajax/10.0/connnection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
sforce.apex.execute("classA","MethodA", {});
alert("execution started." );
Now when I click on Leads tab, page reloads. Button doesn't work and at error console an error message shows:
"sforce not defined."
Case 3: When I change the button type as Detail Page button and add it to the page layout of Lead object, above both cases works fine and apex method starts execution.
I have tested this in Firefox and IE, both browsers has same problem.