Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Export Xml Port Using Codeunit on Server Side

(1) ShareShare
ReportReport
Posted on by

Hi 

In Microsoft Dynamics NAV 2017, I want to run my XMLPort using a Codeunit and save the resulting file in a folder on my desktop. I am running the Codeunit through the Job Queue.

However, I encountered a problem when attempting to include the date and time in the file name. While I successfully implemented the date and time addition, I received an error indicating that the file path is too long.

Additionally, I would like to configure the file path dynamically using the Human Resource Setup .

Here is the code I’m currently using:

HumanResourceSetup.GET();
FileName := FileManagement.ServerTempFileName('xlsx');
ExportFile.CREATE(FileName);
ExportFile.CREATEOUTSTREAM(OutStr);
ExportTour.FILENAME(FileName);
ExportTour.SETDESTINATION(OutStr);
ExportTour.EXPORT;
ExportFile.CLOSE;
FileManagement.DownloadToFile(FileName, 'C:\Users\MyUserID\Desktop\Export Tour.xlsx');
MESSAGE('File has been exported to %1', FileName);
Categories:

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans