<?xml version="1.0" encoding="UTF-8"?>
|
<WebLink xmlns="http://soap.sforce.com/2006/04/metadata">
|
<fullName>SAP_Send_OK</fullName>
|
<availability>online</availability>
|
<displayType>button</displayType>
|
<linkType>javascript</linkType>
|
<masterLabel>SAP上传(Win)</masterLabel>
|
<openType>onClickJavaScript</openType>
|
<protected>false</protected>
|
<url>Ext.select('*[name=sap_send_ok]').set({disabled:'disabled',class:'btnDisabled'}, true);
|
{!RequireScript("/resource/CommonUtilJs")}
|
{!RequireScript("/soap/ajax/51.0/connection.js")}
|
{!RequireScript("/soap/ajax/51.0/apex.js")}
|
//2021-10-22 gwy 版本更改为51.0
|
var foo = function() {
|
var Cocid ='{!Consumable_order__c.Id}';
|
var AgentRef = '{!Consumable_order__c.Dealer_InfoId__c}';
|
var OrderDate = '{!Consumable_order__c.Order_date__c}';
|
var OrderDatenew = OrderDate.replace(/\//g,"-");
|
var recordtypeid = "{!$Label.Consumable_Contract}";
|
|
|
if ('{!Consumable_order__c.Order_status__c}' == '草案中') {
|
alert("请先批准订单");
|
return;
|
}
|
// Recordtype の確認、C、Oはなに?
|
if ('{!Consumable_order__c.Order_status__c}' == '已提交') {
|
alert("请先审批订单");
|
return;
|
}
|
var sql = "select Id,Name from Account where Agent_Ref__c ='" + AgentRef + "' and Contract_Decide_Start_Date__c <= "+ OrderDatenew +" and Contract_Decide_End_Date__c >= "+ OrderDatenew +" and recordtypeid ='"+ recordtypeid +"' order by Contract_Decide_Start_Date__c desc ";
|
var sqlResult = sforce.connection.query(sql);
|
var records = sqlResult.getArray("records");
|
if(records.length==0){
|
alert("经销商无有效合同");
|
return;
|
}
|
if ('{!Consumable_order__c.Opportunity__c}' != '') {
|
alert("已经发送过SAP,不再受理了");
|
return;
|
} else{
|
// insert opportunity
|
// insert opp line item
|
// update opp,opp.SAP_Send_OK__c update to true
|
// update order ,order.SAP_Send_OK__c update to true
|
try{
|
var rs = sforce.apex.execute("SendConsumableordertosap", "sendSAP",{orderId:Cocid});
|
if(rs == ""){
|
alert('上传成功');
|
}else{
|
alert('上传失败' + rs);
|
}
|
}catch(e){
|
alert(e);
|
}
|
window.location.reload();
|
}
|
};
|
foo();</url>
|
</WebLink>
|