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

SunsetSunset 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?
Don't just take my word for it, test it yourself

Best Answer

  • ftorneroftornero Member Posts: 524
    Answer ✓
    Actually is quite simple, in the XML Port write 2 lines with Resource:

    0wqijikht300.png

    You define the second resource like this:

    0kvhx3m0n2he.png


    And assuming that you only want to show this resource when the field es not empty, write this code:

    xloujuwk4dv7.png


    I am using a custom database and some fields in there to emulate what you want to get.

    Regards.

Answers

  • KTA8KTA8 Member Posts: 397
    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.
  • SunsetSunset Member Posts: 201
    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 yourself
  • KTA8KTA8 Member Posts: 397
    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.
  • RockWithNAVRockWithNAV Member Posts: 1,139
    Study Codeunit 6224.
  • SunsetSunset Member Posts: 201
    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 yourself
  • ftorneroftornero Member Posts: 524
    Answer ✓
    Actually is quite simple, in the XML Port write 2 lines with Resource:

    0wqijikht300.png

    You define the second resource like this:

    0kvhx3m0n2he.png


    And assuming that you only want to show this resource when the field es not empty, write this code:

    xloujuwk4dv7.png


    I am using a custom database and some fields in there to emulate what you want to get.

    Regards.
Sign In or Register to comment.