Skip to Content
0

Service Layer Add Delivery Based on a Sales Order

Apr 08 at 07:45 AM

22

avatar image
Former Member

Hi Experts,
I am trying to add a delivery document that is based on a sales order,
i have made a Sales Order with DocEntry = 4445,
using service layer i got the document and started to create the delivery as shown below,

here is the code :

Document SalesOrder = currentOdataService.GetOrderWithDocEntry(DocEntry);
                Document Delivery = new Document();
                Delivery.CardCode = SalesOrder.CardCode;
                Delivery.NumAtCard = "ServiceLayer";
                Delivery.DocDate = DateTime.Today;
                Delivery.DocDueDate = DateTime.Today.AddDays(30);
                for (int i = 0; i < SalesOrder.DocumentLines.Count; i++)
                {
                    DocumentLine newline = new DocumentLine();
                    newline.VatGroup = SalesOrder.DocumentLines[i].VatGroup;
                    newline.ItemCode = SalesOrder.DocumentLines[i].ItemCode.ToString();
                    newline.Quantity = double.Parse(SalesOrder.DocumentLines[i].Quantity.ToString());
                    newline.UoMEntry = int.Parse(SalesOrder.DocumentLines[i].UoMEntry.ToString());
                    newline.WarehouseCode = SalesOrder.DocumentLines[i].WarehouseCode;
                    newline.UnitPrice = double.Parse(SalesOrder.DocumentLines[i].UnitPrice.ToString());
                    newline.BaseEntry = int.Parse(SalesOrder.DocEntry.ToString());
                    newline.BaseLine = int.Parse(SalesOrder.DocumentLines[i].LineNum.ToString());
                    newline.BaseType = 17;
                    Delivery.DocumentLines.Add(newline);
                }
                Document newRetDoc = currentOdataService.AddNewDelivery(Delivery);

All values are fetched good no invalid data,
but i get the following error message :

and when i have removed BaseLine, BaseEntry and BaseType the document is created with no errors....

{
   "error" : {
      "code" : -10,
      "message" : {
         "lang" : "en-us",
         "value" : "Cancelation Date  [DocumentLines.ItemCode][line: 2]"
      }
   }
}
API
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers