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
vagishvagish 

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 ??

Rahul SharmaRahul Sharma

Could you explain your problem in detail?

spraetzspraetz

What is the error?

vagishvagish

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.