function createCharge()
{
debugger;
var new_name=Xrm.Page.getAttribute("new_name").getValue();
//客户名称
var new_accountid = new Array();
new_accountid = Xrm.Page.getAttribute("new_accountid").getValue();
if (new_accountid != null) {
var accountname = new_accountid[0].name;
var accountid = new_accountid[0].id;
accountid=accountid.replace("{","").replace("}","");
var entityType = new_accountid[0].entityType;
}
//套餐名称
var new_packageid = new Array();
new_packageid = Xrm.Page.getAttribute("new_packageid").getValue();
if (new_packageid != null) {
var packagename = new_packageid[0].name;
var packageid = new_packageid[0].id;
packageid=packageid.replace("{","").replace("}","");
var entityType = new_packageid[0].entityType;
}
//折后总价
var new_discount_price=Xrm.Page.getAttribute("new_discount_price").getValue();
//实付金额
var new_actual_pay_amount=Xrm.Page.getAttribute("new_actual_pay_amount").getValue();
//支付状态
var new_pay_status=Xrm.Page.getAttribute("new_pay_status").getValue();
debugger;
//页面赋值
var url = "/CRM/api/data/v9.0/new_charges";
var data = {
new_name:new_name,//名称
"new_accountid@odata.bind":"/accounts("+accountid+")",//客户名称
"new_packageid@odata.bind":"/new_packages("+packageid+")",//套餐名称
new_amount:new_discount_price,//折后总价
new_actually_pay:new_actual_pay_amount,//实付
new_new_pay_status:new_pay_status//结算状态
};
var dataJSON = JSON.stringify(data);
$.ajax({
url:url,
method:"post",
dataType: "json",
contentType:"application/json",
data:dataJSON,
success:function(resp)
{
debugger;
},error:function(resp)
{
alert(resp.responseText);
}
});
}
外加博客,转自:https://blog.csdn.net/vic0228/article/details/50909261。