Insert adjustments document in screen AP302000 of acumatica erp through web services api

泪湿孤枕 提交于 2019-12-25 08:36:02

问题


I need to insert adjusment document (bill doc) in Documents to Apply of the screen Checks and Payments (AP302000). This adjustment document need to insert based on current "Prepayment" document. I need to do this for set off the "prepayment" with the spesific "bill". Note: both of this "Prepayment" and "Bill" documents already released in previous session. So I just have to call spesific reference nbr of Prepayment Doc in header, and then call the spesific Reference Nbr of Bill Doc in Documents to Apply (detail transaction).

Please refer to this screenshot below.

I tried to provide my goal using this code below.

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();
}

But when I debug this code, I got this error message. Please refer to this screenshot below.

Does anyone knows to solve this issue ?


回答1:


On Screen with a type selector before the reference number, you must add an additional action, the insert action.

Also there seem to be an issue with how the page is structured and it is trying to commit the change on the detail level after each and every field entered. So since it doesn't have yet all the required information for it to be valid it return the error you are seeing.

Here is a code sample that should work:

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("admin@Company", "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();
}


来源:https://stackoverflow.com/questions/44195954/insert-adjustments-document-in-screen-ap302000-of-acumatica-erp-through-web-serv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!