AJAX toolkit - webservice execution issue

It's hard for me to understand what is happening here. I am trying to copy some javascript onClick for a button in a Force.com list view for a custom object. Here is js.

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


var myURL = sforce.apex.execute("MyWebServices", "myUrl", {});

and here is the web service I'm trying to call.

global class MyWebServices {

    webservice static String myUrl(){
    return 'www.foo.com';
    }

}

When I click the button, I get a small pop-up warning:

"Problem with JavaScript OnClick for this button or link: Unable to call the 'execute' method from undefined." When I repeat the sforce members, there is no "vertex".

, , . . , script script , . ?

: () - , () - Foo__c.

:

 {!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")}
 {!REQUIRESCRIPT("/soap/ajax/10.0/connection.js")}
 alert( sforce.apex.execute("HammockWebServices", "crossCoverageUrl", {}));

, Foo__c . REQUIRE... .

, , , : JavaScript OnClickJavaScript

, , javascript? (, ...)

+3
3

? , :

var myURL = sforce.apex.execute("MyWebServices", "myUrl", {});

var myURL = sforce.apex.execute("MyNamespace.MyWebServices", "myUrl", {});
0

, connection.js apex.js, .

: apex.js

if (!sforce) {
    throw "unable to find sforce. Make sure that connection.js is loaded before apex.js script";
}

, , , , API? , 10, , Apex ? , , .

0

The “connection” must be indicated to the “top”. It installs the main sforce object.

0
source

Source: https://habr.com/ru/post/1766475/


All Articles