Options

SalesOrderLine Creation error Using NAV SOAP webservice

I am new the NAV. While I am trying to create SalesOrderLine NAV using SOAP Webservice. I am getting "The value "150717D" can't be evaluated into type Date." error. I have posted my sample code below. Please let me know how to fix this error.

Sample Code

//Creating Sales Order in NAV

SalesOrder order = new SalesOrder();
order.Sell_to_Customer_Name = "New highland School";
order.Requested_Delivery_Date = DateTime.Now;
order.VAT_Bus_Posting_Group = "STD";
SOService.Create(ref order);

///Creating SalesOrderLine in NAV
SalesOrderLine sol = new SalesOrderLine();
sol.Type = SalesOrderLineRef.Type.Item;
sol.Document_No = order.No;
sol.Sell_to_Customer_No = "NEWHIGH001002";/// Customer Code
sol.No = "PRDSCHOOLONLY"; /// Product Code
sol.Quantity = 2;
sol.VAT_Prod_Posting_Group = "UK";
sol.Total_VAT_AmountSpecified = false;
sol.Total_Amount_Incl_VATSpecified = false;
sol.TotalSalesLine_Line_AmountSpecified = false;
sol.Total_Amount_Excl_VATSpecified = false;
sos.Create(ref sol);

Answers

  • Options
    JuhlJuhl Member Posts: 724
    You are passing DateTime to Date.

    Also do a insert after setting PK, and then update the rest.
    Follow me on my blog juhl.blog
  • Options
    yuvarajkcbeyuvarajkcbe Member Posts: 4
    edited 2017-08-01

    .
  • Options
    yuvarajkcbeyuvarajkcbe Member Posts: 4
    Juhl wrote: »
    You are passing DateTime to Date.

    Also do a insert after setting PK, and then update the rest.



    Hello Juhl,

    I just passing only following data while creating SalesOrderLine. If possible can you please share any sample code to create record.

    ///Creating SalesOrderLine in NAV
    SalesOrderLine sol = new SalesOrderLine();
    sol.Type = SalesOrderLineRef.Type.Item;
    sol.Document_No = order.No;
    sol.Sell_to_Customer_No = "NEWHIGH001002";/// Customer Code
    sol.No = "PRDSCHOOLONLY"; /// Product Code
    sol.Quantity = 2;
    sol.VAT_Prod_Posting_Group = "UK";
    sol.Total_VAT_AmountSpecified = false;
    sol.Total_Amount_Incl_VATSpecified = false;
    sol.TotalSalesLine_Line_AmountSpecified = false;
    sol.Total_Amount_Excl_VATSpecified = false;
    sos.Create(ref sol);
  • Options
    JuhlJuhl Member Posts: 724
    You using DateTime in header.
    Follow me on my blog juhl.blog
Sign In or Register to comment.