Can I create multiple nodes with the same name using an XMLPort?

Sunset
Member Posts: 201
For an integration to a custom solution I have been asked to extend the logic so that if there are two resources attached to an order, the node saying resources should be listed twice.
The add-on, simplified, is that the resource/person assembling the order is moved to the header, so that when the external software handling the scheduling and assembling the resource is at the top level.
If you imagine that the xml is as follows, you get the idea.
<SalesHeader>
<No>123</No>
<Customer>456</Customer
<Resource>789</Resource>
<Lines>
<Item>A</Item>
<Qty>1</Qty>
<Item>B</Item>
<Qty>2</Qty>
</Lines>
</SalesHeader>
Now they want the solution to handle that sometimes the person assembling the order needs help, and so there are two resources on the order. The logic on the assembly software is set up so that if there are more than 1 node with resource, then the first is the person responsible and everyone else is helping.
So now I need to make two nodes with Resource.
If the integration would have been made using DOM management originally, I would just add the extra node when needed and be done with it. However, since this originally has been made using XMLports, I now face remaking the entire thing or somehow making the XMLport add a resource node if needed.
Since I can define the Min/Max Occurs, it suggests that this could be possible, but I don't see any way of actually achieving this. I can add another Resource node to the XMLPort, but messes up the wdsl, so I am a bit stomped.
Does anybody know how I can make the XMLPort do what I need, or am I stuck with moving everything to being handled by codeunits?
The add-on, simplified, is that the resource/person assembling the order is moved to the header, so that when the external software handling the scheduling and assembling the resource is at the top level.
If you imagine that the xml is as follows, you get the idea.
<SalesHeader>
<No>123</No>
<Customer>456</Customer
<Resource>789</Resource>
<Lines>
<Item>A</Item>
<Qty>1</Qty>
<Item>B</Item>
<Qty>2</Qty>
</Lines>
</SalesHeader>
Now they want the solution to handle that sometimes the person assembling the order needs help, and so there are two resources on the order. The logic on the assembly software is set up so that if there are more than 1 node with resource, then the first is the person responsible and everyone else is helping.
So now I need to make two nodes with Resource.
If the integration would have been made using DOM management originally, I would just add the extra node when needed and be done with it. However, since this originally has been made using XMLports, I now face remaking the entire thing or somehow making the XMLport add a resource node if needed.
Since I can define the Min/Max Occurs, it suggests that this could be possible, but I don't see any way of actually achieving this. I can add another Resource node to the XMLPort, but messes up the wdsl, so I am a bit stomped.
Does anybody know how I can make the XMLPort do what I need, or am I stuck with moving everything to being handled by codeunits?
Don't just take my word for it, test it yourself
0
Best Answer
-
Actually is quite simple, in the XML Port write 2 lines with Resource:
You define the second resource like this:
And assuming that you only want to show this resource when the field es not empty, write this code:
I am using a custom database and some fields in there to emulate what you want to get.
Regards.4
Answers
-
If I understand it right, your main problem is that if a possibility that some data doesn't appear on the file because it insn't needed. You can handle that in the import process. Maybe I don't get your problem.0
-
It is for the export.
The external program uses the webservices that NAV gives to GetOrders, and there the XMLPort is called to export the available data in NAV.Don't just take my word for it, test it yourself0 -
You should be able to do it. You can manipulate the export also. If you can't achieve that using XML default definition, you can use text and reproduce the behaviour, of course that last option it will take more time and effort.0
-
Study Codeunit 6224.Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/-1 -
RockWithNAV wrote: »Study Codeunit 6224.
From the question...
Does anybody know how I can make the XMLPort do what I need, or am I stuck with moving everything to being handled by codeunits?Don't just take my word for it, test it yourself0 -
Actually is quite simple, in the XML Port write 2 lines with Resource:
You define the second resource like this:
And assuming that you only want to show this resource when the field es not empty, write this code:
I am using a custom database and some fields in there to emulate what you want to get.
Regards.4
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions