Sales Orders by WebService
gianmariai
Member Posts: 7
Hello All,
I'm so new to NAV, but got skills in .net development.
I've tried with succes to create new customers using a Page WebService (object ID 21), usng the following code:
Everything works fine, even if I'm not sure this is the right way to do. Anyway.. my problem is on Orders. I've tried to apply same logic on Order creation. I exposed NAV data by web service, again as Page and using object id 48. In code i wrote:
When I execute code i receive the followin message:
It seem i'm violating some rule on insert.. or I'm completely wrong this time.. someone can help? Someone done same thing using Visual Studio to attach NAV WS?
my best regards,
Gianmaria
I'm so new to NAV, but got skills in .net development.
I've tried with succes to create new customers using a Page WebService (object ID 21), usng the following code:
ODataService.Customer c = ODataService.Customer.CreateCustomer("Gianmaria");
c.Name = "AAA New Company";
c.Address = "A Road Name, House Number 5";
c.City = "Rome";
c.Contact = "Mark Jacobs";
c.Country_Region_Code = "IT";
c.E_Mail = "mark@nowhere.it";
c.No = "101";
ODataService.NAV nav = new ODataService.NAV(new Uri("http://win-o490:7048/DynamicsNAV71/OData/"));
nav.AddToCustomer(c);
ICredentials credentials = new NetworkCredential("username", "password");
nav.Credentials = credentials;
try
{
System.Data.Services.Client.DataServiceResponse res = nav.SaveChanges();
}
catch (DataServiceRequestException ex)
{
Exception innerEx = ex.InnerException;
System.Diagnostics.Trace.WriteLine(ex.Message + "\n" + innerEx.Message);
}
Everything works fine, even if I'm not sure this is the right way to do. Anyway.. my problem is on Orders. I've tried to apply same logic on Order creation. I exposed NAV data by web service, again as Page and using object id 48. In code i wrote:
ODataService.SalesOrder order = ODataService.SalesOrder.CreateSalesOrder("Order", "1500", 1);
order.Sell_to_Customer_No = "101";
nav.AddToSalesOrder(order);
try
{
System.Data.Services.Client.DataServiceResponse res = nav.SaveChanges();
}
catch (DataServiceRequestException ex)
{
Exception innerEx = ex.InnerException;
System.Diagnostics.Trace.WriteLine(ex.Message + "\n" + innerEx.Message);
}
When I execute code i receive the followin message:
<?xml version="1.0" encoding="utf-8"?><m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><m:code /><m:message xml:lang="it-IT">An error occurred while processing this request.</m:message><m:innererror><m:message>The underlying application page is not editable.</m:message><m:type>Microsoft.Dynamics.Nav.Service.ODataServiceProvider.ODataException</m:type><m:stacktrace></m:stacktrace></m:innererror></m:error>
It seem i'm violating some rule on insert.. or I'm completely wrong this time.. someone can help? Someone done same thing using Visual Studio to attach NAV WS?
my best regards,
Gianmaria
0
Comments
-
Hi
Check in your Nav Page 48, if the properti EDITABLE of any of the fields you are filling (Document Type, No., ...) is set to FALSE.
If you are inserting information from Web Services, this fields must be editable.
Bye0 -
Thank you for your answer, i founf the solution. I used a different object, the page object 42 and it worked. I think that the object 48 was a read only object.
If i can find somewhere a complete listing of this object with some information it will be very usefull.
thank you again.
If someone need the code i used to insert orders and customers i can post.
Regards,
gianmaria0 -
Hi Gianmaria.
I like your post.
You mentioned if someone wanted the files you could sent them, may I please have these i am trying to learn how to talk to NAV using C#?0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions