通过 Web 服务在 acumatica erp 的屏幕 AP302000 中插入调整文档 api
Insert adjustments document in screen AP302000 of acumatica erp through web services api
我需要在屏幕支票和付款 (AP302000) 的 Documents to Apply 中插入调整文档 (bill doc)。此调整文件需要根据当前 "Prepayment" 文件插入。我需要这样做才能用特定的 "bill" 来衬托 "prepayment"。注意:此 "Prepayment" 和 "Bill" 文档均已在之前的 session 中发布。所以只需要在header中调用Prepayment Doc的specific reference nbr,然后在Documents to Apply(明细交易)中调用Bill Doc的specific Reference nbr即可。
请参考下面的截图。
我尝试使用下面的代码提供我的目标。
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();
}
但是当我调试这段代码时,我得到了这个错误信息。请参考下面的截图。
有谁知道如何解决这个问题?
在参考号前有类型选择器的屏幕上,您必须添加一个附加操作,即插入操作。
页面的结构似乎也有问题,它试图在输入每个字段后提交详细信息级别的更改。因此,由于它还没有使其有效所需的所有信息,因此 return 您看到的错误。
这是一个应该有效的代码示例:
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();
}
我需要在屏幕支票和付款 (AP302000) 的 Documents to Apply 中插入调整文档 (bill doc)。此调整文件需要根据当前 "Prepayment" 文件插入。我需要这样做才能用特定的 "bill" 来衬托 "prepayment"。注意:此 "Prepayment" 和 "Bill" 文档均已在之前的 session 中发布。所以只需要在header中调用Prepayment Doc的specific reference nbr,然后在Documents to Apply(明细交易)中调用Bill Doc的specific Reference nbr即可。
请参考下面的截图。
我尝试使用下面的代码提供我的目标。
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();
}
但是当我调试这段代码时,我得到了这个错误信息。请参考下面的截图。
有谁知道如何解决这个问题?
在参考号前有类型选择器的屏幕上,您必须添加一个附加操作,即插入操作。
页面的结构似乎也有问题,它试图在输入每个字段后提交详细信息级别的更改。因此,由于它还没有使其有效所需的所有信息,因此 return 您看到的错误。
这是一个应该有效的代码示例:
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();
}