web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Export xmlport csv file to local directory

(0) ShareShare
ReportReport
Posted on by 8

Hello everyone,

is it possible to automatically export a csv file form an xmlport into the local directory when the xmlport is run?

thanks in advance

I have the same question (0)
  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at

    You can find some solutions in google for sure

    forum.mibuso.com/.../xmlport-export-save-in-a-destination-automatically

  • Tobias Brighenti Profile Picture
    8 on at

    I already followed the istructions from your link.

    The file is generated but it is empty.

    This is my code:

    CustXmlFile.CREATE('C:\Temp\data.txt');  

    CustXmlFile.CREATEOUTSTREAM(XmlStream);  

    XMLPORT.EXPORT(50002, XmlStream);  

    CustXmlFile.CLOSE;

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    If the file is empty check if you have data in the table from where you are exporting. Are you working on Onprem?

    Thanks.

  • YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 on at

    Hi, It looks like there is no data in xmlport itself, you can try to debug your code.

    And, I'm not sure if the solution below is relevant to your problem, but hope it gives you some new hints.

    http://dynamicslancer.blogspot.com/2017/01/how-to-create-and-save-file-on-local.html

    Thanks.

    ZHU

  • Tobias Brighenti Profile Picture
    8 on at

    I am running the XMLPort from the Development Center.

    After I run it the popup from the client opens where I can view or download the file. That file is not empty and contains the relevant data.

    I need the file to be automatically downloaded to my local directory everytime the XMLPort is run. For that I added the following lines of code in the XMLPort C/AL Editor:

    OnPreXMLport()

    CustXmlFile.CREATE('C:\Temp\data.txt');  

    CustXmlFile.CREATEOUTSTREAM(XmlStream);  

    XMLPORT.EXPORT(50002, XmlStream);

    CustXmlFile.CLOSE;

    Now if I run the XMLPort again, the popup in the client shows up as usual and at the same time a file is created in my local directory. The file although is empty.

    Thanks for your help

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    Hi,

    Can you move your code from OnPreXMLport() to OnPostXMLPort()?

    Thanks.

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    Also this code should not be inside XML Port, it should be run through a action button.

  • Tobias Brighenti Profile Picture
    8 on at

    Thanks for your answer.

    Here a quick summary of my requirements:

    I need a job queue which once a month exports all the sales lines for one specific customer and saves this file in my local directory.

    How would you suggest doing this?

  • Suggested answer
    Mohana Yadav Profile Picture
    60,993 Super User 2025 Season 2 on at

    add the code to a codeunit or processing only report and use that codeunit/report in job queue

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans