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
BBeairdBBeaird 

Javascript remote call from standard page

Is there a way to do Javascript remoting from a button on a standard page?  Or some way to get the same result with a different method?  Basically, I need a button that users can press to kick off a function in another class.

Best Answer chosen by Admin (Salesforce Developers) 
Prafull G.Prafull G.

YOu have to add  javascipt library file. I am unable to post the script code here.

Please try adding it from the link

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_and_ajax.htm

 

All Answers

Prafull G.Prafull G.

You can call Apex Class from javascript. You have to use AJAX for it.

try something like

 

sforce.apex.execute("ApexClassName","methodName",{});

 

where first argument is apex class name, second is method name and the last one in parameters.

 

does it make sense ?

 

BBeairdBBeaird

I tried that originally but am still getting "sforce not defined."  Is there something I have to do externally to include additional javascript files for this?

Prafull G.Prafull G.

YOu have to add  javascipt library file. I am unable to post the script code here.

Please try adding it from the link

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_and_ajax.htm

 

This was selected as the best answer
BBeairdBBeaird

I fixed the problem; the button is calling the webservice now.  I actually had that tag in already, but it did not make a difference.  I'm not sure exactly what fixed it, but I think it was a typo or something in my javascript that called the class.  It's too bad the error message can't be more specific.