Export more than 1 record in an xmlport

victor73victor73 Member Posts: 55
Hello to all,

I am trying to export a set item records based on a filter to an xmlport using the following code

IF EXISTS('C:\Xml_Item.xml') THEN
ERASE('C:\Xml_Item.xml');

TestFile.CREATE('C:\Xml_Item.xml');
TestFile.CREATEOUTSTREAM(TestStream);
gRecItem.SETRANGE(gRecItem.ToSync, TRUE);
IF gRecItem.FINDSET THEN;

lXmlItemSyncEVCprova.SETTABLEVIEW(gRecItem);
lXmlItemSyncEVCprova.SETDESTINATION(TestStream);
lXmlItemSyncEVCprova.EXPORT;
TestFile.CLOSE;

but only the first record of the filter recordset is exported.
Must the xmlport have some kind of particular characteristic?
Or is my code wrong?
Thank you for your time

Comments

  • kinekine Member Posts: 12,562
    All depends on how your XMLPort looks like...
    It must have only one root element, you must "nest" the records into this root element.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • victor73victor73 Member Posts: 55
    Thanks for your answer.
    My xmlport is formed by a root element (Text type) then I have the item table nested underneath and then all the item table fields nested underneath this last one like shown below. Note my last element is a Text field named RealPrimaryKey, i need it for my purposes.

    ItemSync Element Text <ItemSync>
    Item Element Table Item(Item)
    No. Element Field Item::No.
    No._2 Element Field Item::No. 2
    .
    .
    .
    RealPrimaryKey Element Text <RealPrimaryKey>

    So I think that the xmlport structure is correct.
    Tell me if I'm wrong
    Thanks alot
  • kinekine Member Posts: 12,562
    It should work. Check the element property MaxOccurs - it must be <unbounded>.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • victor73victor73 Member Posts: 55
    I checke the property and it was set to Once then I set it to <unbounded>,
    but I still have the same problem it exports only the first rec of the recordset..
    any other suggestions?
  • kinekine Member Posts: 12,562
    Have you set it on the table element or somewhere else?
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • victor73victor73 Member Posts: 55
    Only on the element one based on your suggestion, but note that all the other fields under the element have that property set to <once> as default and I think that is right.
  • ara3nara3n Member Posts: 9,256
    is the table data element set to temporary? Also is it unbounded?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
Sign In or Register to comment.