Friday 21 March 2014

Embedding API Calls in JavaScript
























  • Synchronous Call

    • syntax:
                             sforce.connection.method("arg1","arg2", ...);
                             e.g.
                            sforce.connection.login("MyName@MyOrg.com","myPassword1");



  • Asynchronous call

    • Asynchronous calls allow the client side process to continue, waiting for a call back from the server.
    • To issue an asynchronous call, you must include an additional parameter with the API call, referred to as a callback function.
    • Once the result is ready, the server invokes the callback method with the result.

    • syntax:
                             sforce.connection.method("arg1","arg2", ..., callback_method);                           
                             e.g.
                             var callback = {onSuccess: handleSuccess, onFailure: handleFailure};
                             function handleSuccess(result) {}
                             function handleFailure(error) {}
                             sforce.connection.query("Select name from Account", callback);



Quick Link to parent document: Working with the AJAX Toolkit

No comments:

Post a Comment

Thank you for visiting. Your comments are highly appreciated.