APEX JAVASCRIPT
Apex from Custom button or Javascript : Ajax toolkit
Controller:
1 2 3 4 5 6 |
global class myClass { webService static Id makeContact (String lastName, Account a) { Contact c = new Contact(LastName = lastName, AccountId = a.Id); return c.id; } } |
1 2 3 4 5 |
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")} var account = sforce.sObject("Account"); var id = sforce.apex.execute("myClass" , "makeContact", {lastName:"Smith", a:account}); |
To call a webService method with no parameters, use {} as the third parameter for sforce.apex.execute . Favorite