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

  • Suggested answer
    Mohana Yadav Profile Picture
    60,199 Super User 2025 Season 1 on at
    RE: Export xmlport csv file to local directory

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

  • Tobias Brighenti Profile Picture
    8 on at
    RE: Export xmlport csv file to local directory

    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
    Nitin Verma Profile Picture
    21,465 Moderator on at
    RE: Export xmlport csv file to local directory

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

  • Suggested answer
    Nitin Verma Profile Picture
    21,465 Moderator on at
    RE: Export xmlport csv file to local directory

    Hi,

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

    Thanks.

  • Tobias Brighenti Profile Picture
    8 on at
    RE: Export xmlport csv file to local directory

    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

  • YUN ZHU Profile Picture
    79,380 Super User 2025 Season 1 on at
    RE: Export xmlport csv file to local directory

    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

  • Suggested answer
    Nitin Verma Profile Picture
    21,465 Moderator on at
    RE: Export xmlport csv file to local directory

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

    Thanks.

  • Tobias Brighenti Profile Picture
    8 on at
    RE: Export xmlport csv file to local directory

    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
    Mohana Yadav Profile Picture
    60,199 Super User 2025 Season 1 on at
    RE: Export xmlport csv file to local directory

    You can find some solutions in google for sure

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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,280 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,038 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans