I'm having a hard time understanding what is going on here. I am trying to code up some onClick javascript for a button on a Force.com list view for a custom object. Here's the JS.
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
var myURL = sforce.apex.execute("MyWebServices", "myUrl", {});
and here's the webservice I'm attempting to call.
global class MyWebServices {
webservice static String myUrl(){
return 'www.foo.com';
}
}
When I click the button, I get the little alert pop-up saying:
"A problem with the OnClick JavaScript for this button or link was encountered: Cannot call method 'execute' of undefined" When I iterate the members of "sforce", there is no "apex".
I am using literally the exact same syntax in another button in this same org, the only difference being the methods I am calling. That button works. In fact, if I copy the code from the problem script and put it at the head of the working script on the other button it works. What am I missing here?
Here is further detail on the two buttons element of this issue: One button (that works) is a list view button on Account, the other (broken) one is on a custom object list button for Foo__c.
I use this code for both:
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
alert( sforce.apex.execute("HammockWebServices", "crossCoverageUrl", {}));
on Account it works perfectly, on Foo__c it does not. I've tried switching the order of the !REQUIRE... statements to no observable effect.
Besides the label and name of the buttons they seem to be defined identically: List Button Display Checkboxes Execute JavaScript OnClickJavaScript
Are there object-level permissions, profiles, or sharing rules that affect which javascript packages can be accessed? (Note, that even were this the case, I'm trying this as the sysadmin, and getting nowhere...)