JavaScript buttons jubilee
A neat side effect of the SOAP web service methods we just wrote is that they are now accessible via JavaScript thanks to the AJAX toolkit. What this means to you is that if you have a very simple operation to perform, where going to the edit page is a nuance and a Visualforce page is overkill, you can create an OnClick
JavaScript button. The following snippet is your template:
//Required Import Statements {!REQUIRESCRIPT("/soap/ajax/32.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/32.0/apex.js")} //Call your method, replace variables as needed sforce.apex.execute("CLASS NAME", "METHOD NAME",{PARAM : '{!VALUE}' }); //Refresh the page to show updates to current record location.reload(true);
Tip
If you are not actually modifying ...
Get Learning Apex Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.