How can you call Apex class using Javascript ? Give Example
global class myClass {
webService static Id makeContact (String lastName,
Account a) {
Contact c = new Contact(LastName =
lastName, AccountId = a.Id);
Insert c;
return c.id;
}
}
we can execute above method
from javascript like :
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 .
Also, you can use the
following line to display a popup window with debugging information:
sforce.debug.trace=true;
No comments:
Post a Comment