0
votes

I am creating new Bill in Acumatica using web service API. I wrote below code but it throws exception.

Looking for a solution to below issue. Any help is appreciated.

The button Save is disabled. at PX.Data.PXAction`1.d__c.MoveNext() at PX.Api.SyImportProcessor.SyStep.CommitChanges(Object 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
 }
);

Thanks, Manish

2
please replace ...missing code... with your actual codeMmmh mmh
I fixed it. Thanks, ManishManish

2 Answers

0
votes

here is the example of the code

            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("");
0
votes

Following your comment : "... As soon as i Commment below line, it works. Curious to know why it doesn't work when I add below line. "new Value { Value = "Bill", LinkedCommand = AP301000.DocumentSummary.Type }," My code works ...

Make sure that the invoice type is the first field you set. Using the screen-based API is just like using the screen itself. If you put any field value and then change the type, the whole record is reset. By commenting the AP301000.DocumentSummary.Type command, you basically accepted the default value of the screen, which is usually "Bill".

Your code would become

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