NAV 2013 R2: Webservice in NAV reading multiple records
MMV
Member Posts: 99
Dear All,
I have a requirement where in Webservice consuming application (.Net application) is sending multiple records to NAV. I am using a codeunit in NAV which has XMLPort as a Parameter (VAR). Below is the .Net Application code :
RootDimensions RootDim = new RootDimensions();
List<Dimension> DimList = new List<Dimension>();
if (dimInputCode.Text != "" && dimInputName.Text != "")
{
Dimension Dim = new Dimension();
Dim.DimensionCode = "AREA";
Dim.Code = "1000";
Dim.Name = "1000";
DimList.Add(Dim);
Dim = new Dimension();
Dim.Code = "1003";// dimInputCode.Text;
Dim.Name = "1003"; // dimInputName.Text;
Then we add the single dimension to our list
DimList.Add(Dim);
//To get the list of dimensions "attached" to the root element, we use the following
RootDim.Dimension = DimList.ToArray();
try
{
//Then we send to NAV and show our result
ResultLabel.Text = NAVImport.ImportDim(ref RootDim);
DimList.Clear();
}
catch (Exception ex)
{
//Show a possible exception
ResultLabel.Text = ex.ToString();
}
But when the system reads, the array contains only the last records but twice.
Any idea as to how to read multiple records using Webservice in NAV 2013 R2.
Best Regards,
MMV
I have a requirement where in Webservice consuming application (.Net application) is sending multiple records to NAV. I am using a codeunit in NAV which has XMLPort as a Parameter (VAR). Below is the .Net Application code :
RootDimensions RootDim = new RootDimensions();
List<Dimension> DimList = new List<Dimension>();
if (dimInputCode.Text != "" && dimInputName.Text != "")
{
Dimension Dim = new Dimension();
Dim.DimensionCode = "AREA";
Dim.Code = "1000";
Dim.Name = "1000";
DimList.Add(Dim);
Dim = new Dimension();
Dim.Code = "1003";// dimInputCode.Text;
Dim.Name = "1003"; // dimInputName.Text;
Then we add the single dimension to our list
DimList.Add(Dim);
//To get the list of dimensions "attached" to the root element, we use the following
RootDim.Dimension = DimList.ToArray();
try
{
//Then we send to NAV and show our result
ResultLabel.Text = NAVImport.ImportDim(ref RootDim);
DimList.Clear();
}
catch (Exception ex)
{
//Show a possible exception
ResultLabel.Text = ex.ToString();
}
But when the system reads, the array contains only the last records but twice.
Any idea as to how to read multiple records using Webservice in NAV 2013 R2.
Best Regards,
MMV
0
Answers
-
don't you need to serialize your class first to a xml ?0
-
Hi mdPartnerNL,
The above code works well for a single record. But when I tried to add multiple records, it adds only the last record in the List array.
Best Regards,
MMV0 -
Wouldn't it be much easier to just expose the Dimension List as Web Service and use the ReadMultiple method?"Money is likewise the greatest chance and the greatest scourge of mankind."0
-
Hi einsTeIn.NET,
Thank you for your reply. What is this ReadMultiple? I am using a Codeunit which is exposed and the Codeunit has a function "ImportData" which has a XMLPort parameter.
Could you explain me in little more detail?
Best Regards,
MMV0 -
You can expose any ListPart page as a Web Service and it will automatically provide you with a method call ReadMultiple. Maybe you could use this to get your list of available Dimensions."Money is likewise the greatest chance and the greatest scourge of mankind."0
-
Hi einsTeIn.NET,
I did exactly what you said except that I wanted to insert the data in NAV so I used CreateMultiple and it worked.
Thanks a lot.
=D> =D> =D>
Best Regards,
MMV0
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