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?
Don't just take my word for it, test it yourself
0
Answers
The external program uses the webservices that NAV gives to GetOrders, and there the XMLPort is called to export the available data in NAV.
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
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?
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.