Hi all,
I’m a pretty inexperienced developer so please be gentle! I recently switched jobs, and am looking at creating some custom apps to automatically generate line entries. I have successfully managed to create Purchase Orders, Sales Orders, and Customers, however I cannot figure out how to create or modify line entries at all.
Currently I’m trying this and am getting an index out of array problem where I create the line 1 variable. I have searched high and low, and cannot find anyone else using ODATA services to create line entries. Does anyone have a decent write up bookmarked by chance, or could one of you please help me out. Thanks a bunch
NavOData.NAV nav = new NavOData.NAV(new Uri(“localhost:7048/…/Company(‘CRONUS USA, Inc.’)”));
nav.Credentials = CredentialCache.DefaultNetworkCredentials;
var po = new NavOData.PurchaseOrder
{
Buy_from_Vendor_No = “IC1030”,
Buy_from_Vendor_Name = “Cronus Cardoxy Procurement”,
Buy_from_Address = “Geradeausweg 77”,
Buy_from_City = “Hamburg”,
Buy_from_Post_Code = “DE-20097”,
Buy_from_County = “DE”,
};
nav.AddToPurchaseOrder(po);
var line1 = po.PurchaseOrderPurchLines[0];
{
line1.Type = “Item”;
line1.No = “1000”;
line1.Description = “Bicycle”;
line1.Location_Code = “WHITE”;
line1.Quantity = 1;
line1.Line_Amount = 1;
line1.Direct_Unit_Cost = 1;
line1.Unit_of_Measure_Code = “PCS”;
};
nav.AddToPurchaseOrderPurchLines(line1);
nav.SaveChanges();
Hi Dustin. Did you find a solution to this? I’m trying to do the same thing with Sales Orders and Lines
Thanks
BG
or rather Sales Quotes and Sales Quote Lines
Hello, this may help. forum.mibuso.com/…/odata-add-purchase-invoice-line
You have to add the key fields to the page in Dynamics NAV in order to initiate a new page.
Thanks Thomas. Unfortunately I don’t have access to do this
I switched to SOAP services since I found some documentation online, and got everything working. I can post some code if you have the option of going with SOAP. Once I got the basics figured out it wasn’t too bad. The only thing I struggled with for a bit was iterating through lines via loops, but that was due to my inexperience with development, and not much else. I’m sure a professional developer would cringe at my code, but it works and accounting is loving the extra time.
Hi Dustin, apologies for the delay. I’ve only just seen your reply. I’ve enabled both odata and SOAP so yes, that would be much appreciated, thank you
Are you publishing the default pages of ex. an new page or new query or something else?
I just publishing the existing pages.
Here’s a function I made in C# to create a PO and immediately post/receive it in our primary company (we have 4 companies). You’ll need to add the page as a web reference in Visual Studio which you should be able to find on google fairly easily. The function/codeunit I’m calling to post and receive the order had to be created by my NAV partner as the built in codeunit isn’t exposed through the page for whatever reason.
public static void createEFIPayable(string orderNo, string vendorNo, string glAccountNo, string descriptionOne, decimal quantityTons, decimal unitPrice, string ticketNo, string departmentDim, string commodityDim, DateTime ticketDate)
{
var nav = new EFIPO.PurchaseOrder_Service();
nav.Url = "page address in NAV";
nav.UseDefaultCredentials = true;
var newPO = nav.Read(orderNo);
if (newPO == null)
{
newPO = new EFIPO.PurchaseOrder();
newPO.No = orderNo;
newPO.Buy_from_Vendor_No = vendorNo;
newPO.Vendor_Invoice_No = ticketNo;
newPO.Posting_Date = ticketDate;
newPO.Posting_DateSpecified = true;
nav.Create(ref newPO);
newPO.PurchLines = new Purchase_Order_Line[1];
for (int i = 0; i < 1; i++)
newPO.PurchLines[i] = new Purchase_Order_Line();
nav.Update(ref newPO);
var line1 = newPO.PurchLines[0];
line1.Type = EFIPO.Type.G_L_Account;
line1.No = glAccountNo;
line1.Location_Code = "EFI";
line1.Quantity = quantityTons;
line1.Unit_of_Measure = "TONS";
line1.Unit_of_Measure_Code = "TONS";
line1.Direct_Unit_Cost = unitPrice;
line1.Description = descriptionOne;
line1.Order_Date = ticketDate;
line1.Shortcut_Dimension_1_Code = departmentDim;
line1.ShortcutDimCode3 = commodityDim;
line1.Order_DateSpecified = true;
line1.QuantitySpecified = true;
line1.Total_Amount_Excl_VATSpecified = false;
line1.Total_Amount_Incl_VATSpecified = false;
nav.Update(ref newPO);
nav.PostOrderReceiveAndInvoice(newPO.Key.ToString());
}
}
Here’s another function I made to give you some insight into updating existing lines. The key is that you loop through them and then use a unique value that will return the line you want to modify. You’ll also notice that If I don’t find the value I’m looking for, but have a value then I add the new line to the existing lines.
public void updateExistingContainerSalesLines(string OceanFreight, string InlandFreight, string navItem, decimal containerPrice, decimal estimatedContainerTons, decimal totalBookingTons, string departmentDim, string commodityDim, string countryDim, string estimatedDepartureDate)
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:f1de3f9b-338b-47a7-8474-14a9cf48fae8:type=csharp&text=%20%20%20%20%20%20%20%20public%20void%20updateExistingContainerSalesLines%28string%20OceanFreight%2C%20string%20InlandFreight%2C%20string%20navItem%2C%20decimal%20containerPrice%2C%20decimal%20estimatedContainerTons%2C%20decimal%20totalBookingTons%2C%20string%20departmentDim%2C%20string%20commodityDim%2C%20string%20countryDim%2C%20string%20estimatedDepartureDate%29%0D%0A%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20nav%20%3D%20new%20SalesOrder_Service%28%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20nav.Url%20%3D%20%22SOAP%20Sales%20Order%20Page%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20nav.UseDefaultCredentials%20%3D%20true%3B%0D%0A%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20var%20newSO%20%3D%20nav.Read%28tbBookingRefNumber.Text%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20bool%20itemFound%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20bool%20inlandFreightFound%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20bool%20oceanFreightFound%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20bool%20prepaidInlandFound%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20bool%20outsideHaulingFound%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20if%20%28newSO%20%21%3D%20null%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nav.Update%28ref%20newSO%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.Posting_Date%20%3D%20Convert.ToDateTime%28estimatedDepartureDate%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.Document_Date%20%3D%20Convert.ToDateTime%28estimatedDepartureDate%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.Document_DateSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.Posting_DateSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20%28int%20i%20%3D%200%3B%20i%20%3C%20newSO.SalesLines.Length%3B%20i%2B%2B%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Incl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Excl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Invoice%20%3D%200%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Ship%20%3D%200%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure_Code%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_Date%20%3D%20Convert.ToDateTime%28estimatedDepartureDate%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_DateSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20%28int%20i%20%3D%200%3B%20i%20%3C%20newSO.SalesLines.Length%3B%20i%2B%2B%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28newSO.SalesLines%5Bi%5D.No%20%3D%3D%20navItem%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Description_2%20%3D%20cbBookingNumber.Text%20%2B%20%22%20%22%20%2B%20tbTicketNo.Text%20%2B%20%22%20%22%20%2B%20tbManifestNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode3%20%3D%20commodityDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode7%20%3D%20countryDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Location_Code%20%3D%20%22PORT%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure_Code%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Container_Number%20%3D%20cbContainerNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Quantity%20%3D%20Convert.ToDecimal%28estimatedContainerTons%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_Price%20%3D%20containerPrice%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Ship%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Invoice%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_Date%20%3D%20Convert.ToDateTime%28estimatedDepartureDate%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_PriceSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_DateSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.QuantitySpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Incl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Excl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20itemFound%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20%28int%20i%20%3D%200%3B%20i%20%3C%20newSO.SalesLines.Length%3B%20i%2B%2B%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28newSO.SalesLines%5Bi%5D.No%20%3D%3D%20%22316510%22%20%26%26%20OceanFreight%20%21%3D%20%220%22%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Description_2%20%3D%20cbBookingNumber.Text%20%2B%20%22%20%22%20%2B%20tbTicketNo.Text%20%2B%20%22%20%22%20%2B%20tbManifestNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode3%20%3D%20commodityDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode7%20%3D%20countryDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Quantity%20%3D%20newSO.SalesLines%5Bi%5D.Quantity%20%2B%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Location_Code%20%3D%20%22PORT%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure_Code%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_Price%20%3D%20%28Convert.ToDecimal%28OceanFreight%29%20%2F%20%28Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%29%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Container_Number%20%3D%20cbContainerNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Ship%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Invoice%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_Date%20%3D%20Convert.ToDateTime%28estimatedDepartureDate%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_PriceSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_DateSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.QuantitySpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Incl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Excl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20oceanFreightFound%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20%28int%20i%20%3D%200%3B%20i%20%3C%20newSO.SalesLines.Length%3B%20i%2B%2B%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28newSO.SalesLines%5Bi%5D.No%20%3D%3D%20%22316503%22%20%26%26%20InlandFreight%20%21%3D%20%220%22%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Description_2%20%3D%20cbBookingNumber.Text%20%2B%20%22%20%22%20%2B%20tbTicketNo.Text%20%2B%20%22%20%22%20%2B%20tbManifestNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode3%20%3D%20commodityDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode7%20%3D%20countryDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Quantity%20%3D%20newSO.SalesLines%5Bi%5D.Quantity%20%2B%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Location_Code%20%3D%20%22PORT%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure_Code%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_Price%20%3D%20%28Convert.ToDecimal%28InlandFreight%29%20%2F%20%28Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%29%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Container_Number%20%3D%20cbContainerNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Ship%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Invoice%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_Date%20%3D%20Convert.ToDateTime%28estimatedDepartureDate%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_PriceSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_DateSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.QuantitySpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Incl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Excl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20inlandFreightFound%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20%28int%20i%20%3D%200%3B%20i%20%3C%20newSO.SalesLines.Length%3B%20i%2B%2B%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28newSO.SalesLines%5Bi%5D.No%20%3D%3D%20%22179500%22%20%26%26%20InlandFreight%20%21%3D%20%220%22%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Description_2%20%3D%20cbBookingNumber.Text%20%2B%20%22%20%22%20%2B%20tbTicketNo.Text%20%2B%20%22%20%22%20%2B%20tbManifestNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode3%20%3D%20commodityDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode7%20%3D%20countryDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Quantity%20%3D%20newSO.SalesLines%5Bi%5D.Quantity%20%2B%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Location_Code%20%3D%20%22PORT%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure_Code%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_Price%20%3D%20%28Convert.ToDecimal%28InlandFreight%29%20%2F%20%28Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%29%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Container_Number%20%3D%20cbContainerNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Ship%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Invoice%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_Date%20%3D%20Convert.ToDateTime%28estimatedDepartureDate%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_PriceSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_DateSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.QuantitySpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Incl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Excl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20prepaidInlandFound%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20for%20%28int%20i%20%3D%200%3B%20i%20%3C%20newSO.SalesLines.Length%3B%20i%2B%2B%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28newSO.SalesLines%5Bi%5D.No%20%3D%3D%20%22420100%22%20%26%26%20InlandFreight%20%21%3D%20%220%22%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Description_2%20%3D%20cbBookingNumber.Text%20%2B%20%22%20%22%20%2B%20tbTicketNo.Text%20%2B%20%22%20%22%20%2B%20tbManifestNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode3%20%3D%20commodityDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.ShortcutDimCode7%20%3D%20countryDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Quantity%20%3D%20newSO.SalesLines%5Bi%5D.Quantity%20%2B%20-%28Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Location_Code%20%3D%20%22PORT%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_of_Measure_Code%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_Price%20%3D%20%28Convert.ToDecimal%28InlandFreight%29%20%2F%20%28Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%29%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Container_Number%20%3D%20cbContainerNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Ship%20%3D%20-%28Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Qty_to_Invoice%20%3D%20-%28Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_Date%20%3D%20Convert.ToDateTime%28estimatedDepartureDate%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Unit_PriceSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Shipment_DateSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.QuantitySpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Incl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5Bi%5D.Total_Amount_Excl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20outsideHaulingFound%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28itemFound%20%3D%3D%20false%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%20%3D%20newSO.SalesLines.Concat%28new%5B%5D%20%7B%20new%20Sales_Order_Line%28%29%20%7D%29.ToArray%28%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nav.Update%28ref%20newSO%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Type%20%3D%20EFISO.Type.Item%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.No%20%3D%20navItem%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.ShortcutDimCode3%20%3D%20commodityDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.ShortcutDimCode7%20%3D%20countryDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Description_2%20%3D%20cbBookingNumber.Text%20%2B%20%22%20%22%20%2B%20tbTicketNo.Text%20%2B%20%22%20%22%20%2B%20tbManifestNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Location_Code%20%3D%20%22PORT%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Container_Number%20%3D%20cbContainerNo.Text%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Unit_Price%20%3D%20containerPrice%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Unit_of_Measure%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Unit_of_Measure_Code%20%3D%20%22TONS%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Quantity%20%3D%20Convert.ToDecimal%28estimatedContainerTons%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Qty_to_Ship%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Qty_to_Invoice%20%3D%20Convert.ToDecimal%28tbNetweight.Text%29%20%2F%202000%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Shipment_Date%20%3D%20Convert.ToDateTime%28estimatedDepartureDate%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Unit_PriceSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Shipment_DateSpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.QuantitySpecified%20%3D%20true%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Total_Amount_Incl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Total_Amount_Excl_VATSpecified%20%3D%20false%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28oceanFreightFound%20%3D%3D%20false%20%26%26%20OceanFreight%20%21%3D%20%220%22%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%20%3D%20newSO.SalesLines.Concat%28new%5B%5D%20%7B%20new%20Sales_Order_Line%28%29%20%7D%29.ToArray%28%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20nav.Update%28ref%20newSO%29%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Type%20%3D%20EFISO.Type.G_L_Account%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.No%20%3D%20%22316510%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.Shortcut_Dimension_1_Code%20%3D%20departmentDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Length%20-%201%5D.ShortcutDimCode3%20%3D%20commodityDim%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20newSO.SalesLines%5BnewSO.SalesLines.Le
Wow! Thanks so much Dustin. I’ll test it out just as soon as I get back to the office.
Much appreciated.
Thanks
BG
Thanks Dustin. That was really useful!
I managed to adapt the code you provided to read in the quote header and details from a SQL table into an array. The data in the array is then used in the creation of the quote header and quote details. There were some fields that it didn’t like being left blank, things like Total_Amount_Incl_VAT, PriceExists which was easily remedied by using PriceExistsSpecified = false;. Fortunately I didn’t have to pay our supplier to publish any new code units as WS’s. Everything was available through the std Sales Quote page.
Thanks again
Brian
PConijn
January 13, 2017, 1:16pm
12
Hi Dustin,
It looks like the index-out-of-bounds problem is because you haven’t instantiated the array yet. That should be solved if you add the following prior to the var line1
line:
po.PurchaseOrderPurchLines = new po.PurchaseOrderPurchLines[1]; //Where [1] is the number of lines you want to add
However, you can also try the “Add” method to add it, like I tried below. That will avoid that particular error.
private void AddLine(ref NAVOData.PurchaseInvoice pInvoiceHeader, string pstrItemNo, string pstrDescription, decimal pdecQuantity)
{
giLineNo += 10000;
var newPurchInvLine = new NAVOData.PurchaseInvoicePurchaseLine
{
Line_No = giLineNo,
Type = "Item",
No = pstrItemNo,
Description = pstrDescription,
Quantity = pdecQuantity
};
pInvoiceHeader.PurchaseInvoicePurchaseLine.Add(newPurchInvLine);
}
However, this did not solve my issue. That is that the header gets created just fine, but line creation silently fails. Even if I (manually) added the correct document type and document no. fields to the line entity. The resulting xml looks ok, but only the header gets created.
Below is the resulting xml message (this is the one where I had manually added the correct document type and no. to the lines before sending.
<?xml version="1.0"?>
<PurchaseInvoice xmlns:xsi="[www.w3.org/.../XMLSchema-instance"](http://www.w3.org/2001/XMLSchema-instance) xmlns:xsd="[www.w3.org/.../XMLSchema">](http://www.w3.org/2001/XMLSchema)
<Document_Type>Invoice</Document_Type>
<Buy_from_Vendor_No>9420</Buy_from_Vendor_No>
<Vendor_Invoice_No>SI17-03498</Vendor_Invoice_No>
<Vendor_Shipment_No>SS17-03498</Vendor_Shipment_No>
<Vendor_Order_No>SO17-03497</Vendor_Order_No>
<PurchaseInvoicePurchaseLine>
<PurchaseInvoicePurchaseLine>
<Document_Type>Invoice</Document_Type>
<Document_No>PIN-007625</Document_No>
<Line_No>10000</Line_No>
<Type>Item</Type>
<No>ITEM100</No>
<Buy_from_Vendor_No>9420</Buy_from_Vendor_No>
<Description>Hullabaloo</Description>
<Quantity>10</Quantity>
</PurchaseInvoicePurchaseLine>
<PurchaseInvoicePurchaseLine>
<Document_Type>Invoice</Document_Type>
<Document_No>PIN-007625</Document_No>
<Line_No>20000</Line_No>
<Type>Item</Type>
<No>ITEM99</No>
<Buy_from_Vendor_No>9420</Buy_from_Vendor_No>
<Description>Thingamajig</Description>
<Quantity>50</Quantity>
</PurchaseInvoicePurchaseLine>
</PurchaseInvoicePurchaseLine>
</PurchaseInvoice>