Update data in NAV via C#
Majestic
Member Posts: 10
Hello
ill try and make this short:
i have been trying to update some data in Nav from C#, but whatever i do i get errors:
my code Unit looks like this:
Since i havent created the web service myself im provideing the above code in hopes that there might be something wrong with it. (created by a friend/college).
anyway, moveing on to C#, i can get the data over to C# and review it. Now i want to update a "vogn" with the method.
at the moment my code looks like this:
i have exposed the NAV service as a Web Reference.
im running out of patience, and hopefully one of you guys can help me here ](*,)
ill try and make this short:
i have been trying to update some data in Nav from C#, but whatever i do i get errors:
my code Unit looks like this:
<operation name="OpdaterVogn"> <operation soapAction="urn:microsoft-dynamics-schemas/codeunit/BMG:OpdaterVogn" style="document"/> <input name="OpdaterVogn"> <body use="literal"/> </input> <output name="OpdaterVogn_Result"> <body use="literal"/> </output> </operation>afaik this is my method i need to use, to update the record in NAV. i need to update a "Vogn", and in my codeunit i get the following "class" i need to update with.
<schema elementFormDefault="qualified" targetNamespace="urn:microsoft-dynamics-nav/xmlports/x78001"> <complexType name="VognType"> <sequence> <element minOccurs="1" maxOccurs="1" name="Kode" type="string"/> <element minOccurs="1" maxOccurs="1" name="RegNr" type="string"/> <element minOccurs="1" maxOccurs="1" name="Beskrivelse" type="string"/> <element minOccurs="1" maxOccurs="1" default="false" name="Spaerret" type="boolean"/> </sequence> </complexType> <complexType name="Vogn" mixed="true"> <sequence> <element minOccurs="1" maxOccurs="unbounded" name="Vogn" type="tns:VognType"/> </sequence> </complexType><element name="Vogn" type="tns:Vogn"/> </schema>
Since i havent created the web service myself im provideing the above code in hopes that there might be something wrong with it. (created by a friend/college).
anyway, moveing on to C#, i can get the data over to C# and review it. Now i want to update a "vogn" with the method.
at the moment my code looks like this:
Vogn vogneNy = new Vogn();
VognType vognNy = new VognType();
ws.SendVogn("BMG 2013", false, ref vogneNy);
vogneNy.Vogn1[0].Beskrivelse = "lol";
ws.OpdaterVogn("BMG 2013", vogneNy);
i get the following error: The Vogn already exists. Identification fields and values: Kode='FF1D57CC0i have exposed the NAV service as a Web Reference.
im running out of patience, and hopefully one of you guys can help me here ](*,)
0
Answers
-
quick update:
i try and add the data to a list and thereafter send that to NAVVogn vogneNy = new Vogn(); VognType vognNy = new VognType(); List<VognType> list = new List<VognType>(); vognNy.Kode = kode; // string value to update vognNy.Beskrivelse = beskrivelse; // string value to update vognNy.RegNr = regnr; // string value to update vognNy.Spaerret = spaerret; // Bool value to update list.Add(vognNy); vogneNy.Vogn1 = list.ToArray(); ws.OpdaterVogn("BMG 2013", vogneNy);
new Error: {"The Element <Kode> is expected by Min Occurs value: Once. Element received: <>."}0 -
Hi,
I personally dont really like the list approach because nav often has its difficulties with it in my experience.
Frankly, there seems to be something wrong with the Codeunit.
Best of Luck
WisaAustrian NAV/BC Dev0 -
there was indeed something wrong with the codeUnit, its all fixed now
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