I am inserting new data to a NAV page via the OData web services.
One test i am attempting is inserting a sales invoice, and a related sales line.
The sales invoice header inserts just fine.
But i was wondering:
1. how i can get the document no from that new sales invoice record?
2. The sales invoice line i add doesn't get inserted -- no error, i just don't know if it is linked properly to the parent sales invoice record
Integration_Sales_Invoice newSalesInvoice = new Integration_Sales_Invoice();
newSalesInvoice.Bill_to_Customer_No = "1113";
newSalesInvoice.Bill_to_Name = "Test BillTo";
newSalesInvoice.Document_Date = Convert.ToDateTime("2016-03-21");
newSalesInvoice.Due_Date = Convert.ToDateTime("2016-04-22");
newSalesInvoice.Shipment_Date = Convert.ToDateTime("2016-03-22");
newSalesInvoice.Sell_to_Customer_No = "1113";
newSalesInvoice.Sell_to_Customer_Name = "Test Customer";
nav.AddToIntegration_Sales_Invoice( newSalesInvoice);
Integration_Sales_InvoiceSalesLines newSalesInvoiceLine = new Integration_Sales_InvoiceSalesLines();
nav.AddToIntegration_Sales_InvoiceSalesLines(newSalesInvoiceLine);
newSalesInvoiceLine.Type = "Resource";
newSalesInvoiceLine.Description = "Scheduled Work";
newSalesInvoiceLine.Quantity = Convert.ToDecimal(2.5);
newSalesInvoiceLine.Unit_of_Measure_Code = "HR";
newSalesInvoiceLine.Unit_Price = Convert.ToDecimal(125.00);
newSalesInvoiceLine.Line_Amount = Convert.ToDecimal(312.50);
newSalesInvoiceLine.Amount_Including_VAT = Convert.ToDecimal(312.50);
newSalesInvoice.Integration_Sales_InvoiceSalesLines.Add(newSalesInvoiceLine);
nav.SaveChanges();
*This post is locked for comments
hi TDawg,
the reason is you publish a subform but in that subform there's document field and line no.
you can add these 2 fields to subform and set the visible property to 'false'
Cheers
I was mistaken in my original question --- the line was erroring when saving. it stated it did not have a document no. So... if i choose to use the auto id creation for the sales invoice --- can i get back that ID? Or... is there a way to generate a new ID that i can then assign to the sales invoice, and subsequent sales invoice lines?
Have you checked in the sales line table, if the record is inserted or not?
Also try with manual Document No. and see the result.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156