Salesforce使用JS操作数据库

1,直接查询

`{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")} 
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")} 
var haveQuote = "{!Opportunity.xxx}"; 
var oppStage = "{!Opportunity.yyy}"; 
if(haveQuote != '' && oppStage=='Bidding'){ 
	var areYouSure = confirm('xxxx?');  //
	if(areYouSure){ 
		//remove approval status
		var newQuote = new sforce.SObject("Quote"); 
		newQuote ["Id"] = "{!Quote.Id}"; 
		newQuote ["xxx_Status__c"] = "New"; 
		**var result = sforce.connection.update([newOpp]);** 
		if(result[0].getBoolean("success")){ 
			window.location=("/apex/xxxpage?id={!Quote.Id}"); 
		}else{ 
			alert('Update Quote Action Failed,Please Contact Administrator!'); 
		} 		
	} 
}else{
	alert('You Can\'t xxx. '); 
}`

2,调用webService

var res = sforce.apex.execute("xxxClass","ClassMethod",{ 参数: "{!Account.Id}"}); 
console.log("exceute result:"+res); 
var result = String(res).split("="); 
console.log("result:"+result); 
if(result[0] == "S") 
{ 
alert(result[1]); 
window.location.reload(); 
} 

你可能感兴趣的:(Salesforce,开发)