0

我正在使用 Web 服务 API 在 Acumatica 中创建新的比尔。我写了下面的代码,但它抛出了异常。

寻找以下问题的解决方案。任何帮助表示赞赏。

按钮保存被禁用。在 PX.Data.PXAction`1.d__c.MoveNext() 在 PX.Api.SyImportProcessor.SyStep.CommitChanges(对象 itemToBypass,PXFilterRow[] targetConditions)

AP301000Content AP301000Header = context.AP301000GetSchema();
context.AP301000Clear();
AP301000Content[] AP301000ImportHeaderResult = context.AP301000Submit
 (
 new Command[]
 {
   new Value { Value = "ARKTAK", LinkedCommand = AP301000Header.DocumentSummary.Vendor },
 new Value { Value = "Bill", LinkedCommand = AP301000Header.DocumentSummary.Type },

 new Value {Value = "ARKTAK ref123", LinkedCommand = AP301000Header.DocumentSummary.VendorRef },
 new Value{Value = "False", LinkedCommand = AP301000Header.DocumentSummary.Hold },

 new Value{Value = "MAIN  ", LinkedCommand = AP301000Header.DocumentSummary.Location },
 new Value{Value = "90D", LinkedCommand = AP301000Header.DocumentSummary.Terms },
 new Value{Value = "3/8/2015", LinkedCommand = AP301000Header.DocumentSummary.DueDate },
 new Value{Value = "12/8/2014", LinkedCommand = AP301000Header.DocumentSummary.CashDiscountDate },

new Value{ Value = "MAIN", LinkedCommand = AP301000Header.FinancialDetailsLinkToGL.Branch},   
new Value{ Value = "200000", LinkedCommand = AP301000Header.FinancialDetailsLinkToGL.APAccount},   
new Value{ Value = "US-00-00-US-000", LinkedCommand = AP301000Header.FinancialDetailsLinkToGL.APSubaccount},   

 new Value{ Value = "3/8/2015", LinkedCommand = AP301000Header.FinancialDetailsDefaultPaymentInfo.PayDate},   
new Value{ Value = "MAIN", LinkedCommand = AP301000Header.FinancialDetailsDefaultPaymentInfo.Location},   



  AP301000Header.Actions.Save, AP301000Header.DocumentSummary.ReferenceNbr
 }
);

谢谢,马尼什

4

2 回答 2

0

这是代码示例

            AP301000Content AP301000 = context.AP301000GetSchema();
        context.AP301000Clear();

        try
        {
            AP301000Content[] AP301000Content = context.AP301000Submit
            (
                new Command[]
                {
                    new Value { Value = "Bill", LinkedCommand = AP301000.DocumentSummary.Type },
                    new Value { Value = "='new'", LinkedCommand = AP301000.DocumentSummary.ReferenceNbr },

                    new Value { Value = "ACITAISYST", LinkedCommand = AP301000.DocumentSummary.Vendor},                        
                    new Value { Value = "123", LinkedCommand = AP301000.DocumentSummary.VendorRef},
                    new Value { Value = "TEST", LinkedCommand = AP301000.DocumentSummary.Description},

                    AP301000.DocumentDetails.ServiceCommands.NewRow,                                                
                    new Value { Value = "ACCOMODATION", LinkedCommand = AP301000.DocumentDetails.InventoryID},
                    new Value { Value = "1.0", LinkedCommand = AP301000.DocumentDetails.Quantity},
                    new Value { Value = "10.00", LinkedCommand = AP301000.DocumentDetails.UnitCost},
                    new Value { Value = "X", LinkedCommand = AP301000.DocumentDetails.Project},

                    AP301000.Actions.Save,
                    AP301000.DocumentSummary.ReferenceNbr
                }
            );

            Console.WriteLine(AP301000Content[0].DocumentSummary.ReferenceNbr.Value);
        }
        catch (Exception ex)
        {

        }
        Console.WriteLine("");
于 2014-12-08T12:12:46.707 回答
0

按照您的评论:“...只要我在下面的行评论,它就会起作用。很想知道为什么当我在下面添加时它不起作用。”新值 { 值 =“比尔”,LinkedCommand = AP301000.DocumentSummary。输入},”我的代码有效...

确保发票类型是您设置的第一个字段。使用基于屏幕的 API 就像使用屏幕本身一样。如果您输入任何字段值然后更改类型,则重置整个记录。通过注释 AP301000.DocumentSummary.Type 命令,您基本上接受了屏幕的默认值,通常为“Bill”。

你的代码会变成

AP301000Content AP301000Header = context.AP301000GetSchema();
context.AP301000Clear();
AP301000Content[] AP301000ImportHeaderResult = context.AP301000Submit(
 new Command[] {
  new Value {
   Value = "Bill", LinkedCommand = AP301000Header.DocumentSummary.Type
  },
  new Value {
   Value = "ARKTAK", LinkedCommand = AP301000Header.DocumentSummary.Vendor
  },


  new Value {
   Value = "ARKTAK ref123", LinkedCommand = AP301000Header.DocumentSummary.VendorRef
  },
  new Value {
   Value = "False", LinkedCommand = AP301000Header.DocumentSummary.Hold
  },

  new Value {
   Value = "MAIN  ", LinkedCommand = AP301000Header.DocumentSummary.Location
  },
  new Value {
   Value = "90D", LinkedCommand = AP301000Header.DocumentSummary.Terms
  },
  new Value {
   Value = "3/8/2015", LinkedCommand = AP301000Header.DocumentSummary.DueDate
  },
  new Value {
   Value = "12/8/2014", LinkedCommand = AP301000Header.DocumentSummary.CashDiscountDate
  },

  new Value {
   Value = "MAIN", LinkedCommand = AP301000Header.FinancialDetailsLinkToGL.Branch
  },
  new Value {
   Value = "200000", LinkedCommand = AP301000Header.FinancialDetailsLinkToGL.APAccount
  },
  new Value {
   Value = "US-00-00-US-000", LinkedCommand = AP301000Header.FinancialDetailsLinkToGL.APSubaccount
  },

  new Value {
   Value = "3/8/2015", LinkedCommand = AP301000Header.FinancialDetailsDefaultPaymentInfo.PayDate
  },
  new Value {
   Value = "MAIN", LinkedCommand = AP301000Header.FinancialDetailsDefaultPaymentInfo.Location
  },

  AP301000Header.Actions.Save, AP301000Header.DocumentSummary.ReferenceNbr
 }
);
于 2017-07-26T18:24:54.767 回答