2017-05-26 24 views
0

我需要在文檔中插入調整文檔(bill doc)以應用屏幕支票和付款(AP302000)。該調整文件需要根據當前的「預付」文件來插入。我需要這樣做才能用特別的「賬單」來抵消「預付款」。注意:這個「預付款」和「賬單」文件都已在上一次會議中發佈。因此,我只需在頭文件中調用Prepayment Doc的特定參考號,然後在要應用的憑證(詳細交易)中調用Bill Doc的特定參考號。通過web服務API在acumatica erp的屏幕AP302000中插入調整文檔

請參考下面的截圖。

enter image description here

我試過下面使用此代碼提供我的目標。

context.CookieContainer = new System.Net.CookieContainer(); 
context.Timeout = System.Threading.Timeout.Infinite; 
context.Url = "http://localhost/AcuInterface/(W(3))/Soap/SOD.asmx"; 
LoginResult result = context.Login("admin", "123"); 
AP302000Content checkSchema = context.AP302000GetSchema(); 
List<Command> cmds = new List<Command>(); 
cmds.Add(new Value { LinkedCommand = checkSchema.PaymentSummary.Type, Value = "Prepayment" }); 
cmds.Add(new Value { LinkedCommand = checkSchema.PaymentSummary.ReferenceNbr, Value = "1600001331"}); 
cmds.Add(checkSchema.DocumentsToApply.ServiceCommands.NewRow); 
cmds.Add(new Value { LinkedCommand = checkSchema.DocumentsToApply.DocumentType, Value = "Bill" }); 
cmds.Add(new Value { LinkedCommand = checkSchema.DocumentsToApply.ReferenceNbrAdjdRefNbr, Value = "1600003050"}); 
cmds.Add(new Value { LinkedCommand = checkSchema.DocumentsToApply.AmountPaid, Value = "80000" }); 
try 
{ 
     cmds.Add(checkSchema.Actions.Save); 
     var result = context.AP302000Submit(cmds.ToArray()); 
} 
catch (Exception ex) 
{ 
     MessageBox.Show(ex.Message); 
} 
finally 
{ 
     context.Logout(); 
} 

但是,當我調試此代碼時,我收到此錯誤消息。請參考下面的截圖。

enter image description here

有誰知道解決這個問題?

+0

嘗試設置'了'PaymentSummary'支付Amount'保存之前 –

+0

我已經嘗試過了,我說這句法:cmds.Add(新價值{LinkedCommand = checkSchema.PaymentSummary.PaymentAmount,Value =「80000」});我仍然得到相同的錯誤.. – HariEko

回答

0

在參考編號之前帶有類型選擇器的屏幕上,您必須添加其他操作,即插入操作。

此外,頁面的結構似乎也存在問題,並且在輸入每個字段後嘗試在詳細級別上進行更改。因此,由於它尚未具備所有必需的信息以使其有效,它將返回您所看到的錯誤。

下面是一個代碼示例,應該工作:

context.CookieContainer = new System.Net.CookieContainer(); 
context.Timeout = System.Threading.Timeout.Infinite; 
context.Url = "http://localhost/Demo610u05/(W(346))/Soap/AP302000.asmx"; 
LoginResult result = context.Login("[email protected]", "admin"); 
AP302000Content checkSchema = context.AP302000GetSchema(); 

var detailTypeNoCommit = checkSchema.DocumentsToApply.DocumentType; 
detailTypeNoCommit.Commit = false; 
var detailRefNbrNoCommit = checkSchema.DocumentsToApply.ReferenceNbrAdjdRefNbr; 
detailRefNbrNoCommit.Commit = false; 
var detailamountPaidNoCommit = checkSchema.DocumentsToApply.AmountPaid; 
detailamountPaidNoCommit.Commit = false; 

List<Command> cmds = new List<Command>(); 
cmds.Add(new Value { LinkedCommand = checkSchema.PaymentSummary.Type, Value = "Prepayment" }); 
cmds.Add(checkSchema.Actions.Insert); 
cmds.Add(new Value { LinkedCommand = checkSchema.PaymentSummary.ReferenceNbr, Value = "1600001331"}); 
cmds.Add(checkSchema.DocumentsToApply.ServiceCommands.NewRow); 
cmds.Add(new Value { LinkedCommand = detailTypeNoCommit, Value = "Bill" }); 
cmds.Add(new Value { LinkedCommand = detailRefNbrNoCommit, Value = "1600003050"}); 
cmds.Add(new Value { LinkedCommand = detailamountPaidNoCommit, Value = "80000" }); 
try 
{ 
    cmds.Add(checkSchema.Actions.Save); 
    var result = context.AP302000Submit(cmds.ToArray()); 
} 
catch (Exception ex) 
{ 
     MessageBox.Show(ex.Message); 
} 
finally 
{ 
    context.Logout(); 
} 
+0

嗨@ samol518,謝謝你的迴應。我已經試過你的示例代碼到我的項目,它的工作原理。非常感謝你 :) – HariEko