1,创建 Custom Button 在页面上
2, 创建CustomJs 代码调用Webservice
<!--参数名区分大小写,对于跨层object直接在Object名后直接加参字段名即可-->
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")} var OppID='{!Opportunity.Id}'
var OppName = '{!Opportunity.OwnerLastName},{!Opportunity.OwnerFirstName}'
var hello = sforce.apex.execute("WSReturn", "Hello", {id:OppID,username:OppName});
alert(hello);
3,编写Webservice代码
global class WSReturn {
webservice static string Hello(string id,string username){
string sayHello; sayHello = 'Hi '+username+', your id is:'+id;
system.debug('say hello'); return sayHello;
}
}