How to Insert empty record in XMLPort

biant123biant123 Member Posts: 29
edited 2012-05-18 in NAV Three Tier
Hi,

I have created a XMLport that can import and export records in text. The XMLport is being called from a report by .export or .import.
I have few different tables in the xmlport, but some of the tables might have empty record, so I need to insert empty line to the text file if the table is empty during Export (it does in dataport). Otherwise during Import, if the empty line does not exist, the XMLport will read the wrong record/text from the file.

Any idea how to insert the empty line to represent the record is empty? Like it does in dataport? :-k

Comments

  • thegunzothegunzo Member Posts: 274
    If you have MinOccurs = Once property on an Element you will always get the element exported.
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • biant123biant123 Member Posts: 29
    Hi Gunnar,

    Thanks for your reply.

    Yea, it only exports the element if the Format is XML, but i need to export text instead :(.
  • thegunzothegunzo Member Posts: 274
    Then your solutions is to use temporary records and check for the need to install an empty record before you start the export.
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • biant123biant123 Member Posts: 29
    Hi Gunnar,

    I have already tried to use temp record and insert an empty record to the temp table before export, so the text result is:

    1st record xxxxxx

    2nd record yyyyy

    ,,0.00,,

    4th record zzzzz


    But is it possible to get a total empty line instead? For example:

    1st record xxxxxx

    2nd record yyyyy



    4th record zzzzzz
  • thegunzothegunzo Member Posts: 274
    By only using a Text[1024] string in the xmlport and code similar to this
    IF DecimalValue = 0 THEN 
      TextValue = '' 
    ELSE 
      TextValue = <Formatted string from all record fields>;
    
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • biant123biant123 Member Posts: 29
    Hi Gunnar,

    Hmm... I am not sure if we are thinking the same approach? I have make a simple XMLport (as shown below) to try on as my original xmlport has too many tables.

    on my XMLport:
    Node Name Node Type Source Type Data Source
    Root Element Text <Root>
    Customer Element Table <Customer>(Customer)
    no Element Field Customer::No.
    name Element Field Customer::Name
    ReasonCode Element Table <Reason Code>(Reason Code)
    code Element Field Reason Code::Code
    description Element Field Reason Code::Description
    amt Element Field Reason Code::Contract Gain/Loss Amount

    I have set the table as Temporary.
    On each table Export::OnPreXMLItem(), i insert an empty record to the temp table:

    IF gReasonCode.ISEMPTY THEN BEGIN
    "Reason Code".INIT;
    "Reason Code".INSERT;
    END;

    and i call this xmlport from a report by using xmlport.export

    So how do you write the empty line?
  • thegunzothegunzo Member Posts: 274
    You remove all elements with the type Field and insert one with the type text. Then create the text value from the record data
    ________________________________
    Gunnar Gestsson
    Microsoft Certified IT Professional
    Dynamics NAV MVP
    http://www.dynamics.is
    http://Objects4NAV.com
  • biant123biant123 Member Posts: 29
    Thanks for your feedback. That's no point of using XMLport then if that's the case.
Sign In or Register to comment.