NAV 4.0 Export Data in XML File using XMLPort

dipakpatel2505dipakpatel2505 Member Posts: 169
edited 2014-11-18 in Navision Attain
Dear All,

In Nav 4.0, I have trying to export Customer List in XML file Format using XMLPort and Codeunit.

I am facing problem and not able to export data in XML file in Nav 4.0. Navision crashes when I try to export data in XML file using code as below: I have also attached XML Port design snapshot.

I have tries same code in Navision 2009 R2 and it has export XML File successfully. Is it XML Port Limitation in Nav 4.0 that it can not export data in XML Format. Any suggestion/help to solve my problem is appriciate.
Codeunit : OnRun() Trigger

IF EXISTS('D:\Test\Customer.xml') THEN
ERASE('D:\Test\Customer.xml');

CLEAR(TestFile);
CLEAR(TestStream);

XMLFileName := 'D:\Test\Customer.xml';

TestFile.CREATE(XMLFileName);
FileOpened := TestFile.OPEN(XMLFileName);

TestFile.CREATEOUTSTREAM(TestStream);
CustomExport.SETDESTINATION(TestStream);
CustomExport.EXPORT;
TestFile.CLOSE;

MESSAGE('XML Customer Export Complete.');

Comments

  • manisharma31manisharma31 Member Posts: 285
    Dipak,
    Did you find any solution for this issue.
    We are facing the same issue.
    Regards,
    Manish
  • KishormKishorm Member Posts: 921
    Is your code the same as Dipak's? If so then try deleting the following line of code...
    FileOpened := TestFile.OPEN(XMLFileName);
    

    ...I'm not sure if that is the problem or not (maybe it opens the file in read only mode) but it shouldn't really be there.

    If that doesn't fix it then show us the code you are using and highlight which line of code is causing the crash (you can use the debugger to step through the code).
Sign In or Register to comment.