How can I retrieve existing ‘Opportunity’ object with Java script (on Sales application)?
custom button’s javaScript ‘onClick’ section.
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
//Get Opportunity object
var op = "{<Retrieve Opportunity Object ?>}";
//Call insertJob method by passing that Opportunity object
sforce.apex.execute("JobService","insertJob",{o:op});
Apex Class.
global class JobService {
webService static void insertJob(Opportunity o) { }
}
This code uses the merge syntax to get the opportunity Id: