Skip to Content
0
May 25, 2018 at 02:39 PM

B1 DI API Get DocTotal on Document

326 Views Last edit May 25, 2018 at 02:40 PM 2 rev

Hi. I'm trying to add a sales order in B1 using the DI API. I want to check the DocTotal field to make sure the total amount matches what I'm trying to add. When I check the DocTotal however, it always shows a 0 value. I notice it returns a correct value when I add the sales order and then pull it back up using GetByKey. I'd like to check the DocTotal value before I actually add the document however.

This is the code I'm testing with:

order.CardCode = "TESTBP";
order.DocDueDate = order.DocDate;
order.Expenses.ExpenseCode = 1; //freight expense;
order.Expenses.LineTotal = 42.50;
order.Lines.ItemCode = "TESTITEM5";
order.Lines.Quantity = 5;
order.Lines.UnitPrice = 15.00;
order.Lines.Add();
order.DocTotal at this point always returns 0.

Thanks!