Problem with creation of Sales Order with NAV web services

Dear Frends,

I have one issue and hope that you maybe can help me.
Namely, I want to make one web service which will create Sales Order in Dynamics. In this process I am very close to the end but have one problem for which need assistence from somebody who has a reach experience with NAV web services developing.

This is web services which I made in C#

public string CreateSalesOrderNAvision()

// Create Service Reference
SalesOrder1_Service service = new SalesOrder1_Service();

service.UseDefaultCredentials = true;

service.Url = “http://mascnl:7047/DynamicsNAV/ws/CRONUS_International_Ltd/Page/SalesOrder1”;

// Create the Order header
SalesOrder1.SalesOrder1 newOrder = new SalesOrder1.SalesOrder1();

service.Create(ref newOrder);

newOrder.Sell_to_Customer_No = “38128456”;
newOrder.Order_Date = DateTime.Today;

newOrder.SalesLines = new Sales_Order_Line[2];

for (int idx = 0; idx < 2; idx++)
newOrder.SalesLines[idx] = new SalesOrder1.Sales_Order_Line();

service.Update(ref newOrder);

Sales_Order_Line line1 = newOrder.SalesLines[0];
line1.Type = SalesOrder1.Type.Item;
line1.TypeSpecified = true;
line1.No = “L1976-W”;
line1.Quantity = 3;
line1.QuantitySpecified = true;

Sales_Order_Line line2 = newOrder.SalesLines[1];
line2.Type = SalesOrder1.Type.Item;
line2.TypeSpecified = true;
line2.No = “L1976-W”;
line2.Quantity = 33;
line2.QuantitySpecified = true;

service.Update(ref newOrder);

return “Order Created”;


But when want to execute this web services get this error message :
System.Web.Services.Protocols.SoapException: The date is not valid.
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at SalesOrder1.SalesOrder1_Service.Update(SalesOrder1& SalesOrder1) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\websiteskeltanav\a7712f9a\62ad9408\App_WebReferences.xktyv-k8.1.cs:line 301
at Service.HelloWorld() in c:\Inetpub\wwwroot\WebSiteSkeltaNAV\App_Code\Service.cs:line 43

Can somebody help me and offer a good solution for Sales Order creation with web services.

thanks in advance

You are attempting to create a Navision record outside of Navision this is generally not good practice but;

First create your sample Sales Order inside of Navision (manually create the Sales Order), then read the record back using .NET this will show you the fields that are hidden even from Navision. Plus it will give you a good understanding of fields that should be filled in.

Are you going to have someone later on Validate the Sales Order fields, many triggers are called as you enter fields on a Sales Order that update and check other fields?

We are doing something similar with the exception that we generate a flat file from the online order, and Navision picks it up using a dataport and generates the Order.


Stomar :

From your web service DO NOT create the sales order directly by inserting record in table 36 or 37, but instead create a process table like Web Sales Order, insert your order in this table, and then from Navision create a Codeunit that read this table and create the Navision Sales Order document, this will give you a lot more flexibility for error & exceptions handling

As John pointed out, you’re not triggering all the validation code that are on those table