Insert adjustments document in screen AP302000 of

2019-09-14 07:55发布

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.

enter image description here

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.

enter image description here

Does anyone knows to solve this issue ?

1条回答
劫难
2楼-- · 2019-09-14 08:42

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();
}
查看更多
登录 后发表回答