In NAV 2016, how can I get the XMLport to save a file without any interaction from the user?

vimo
Member Posts: 14
Hello!
I have an XMLport that exports a report to a CSV file. No issues there. When the XMLport runs, I would like the file to be saved to the export folder without the Export File Dialog box opening and asking: “Do you want to open or save this file?” See Image1. There is a checkbox that I can uncheck “Always ask before opening this type of file.” But when I uncheck it,the Export dialog box still opens up, see Image2, with the correct export folder automatically selected, but I still need to click the Save button.
How can I get the XMLport to Save a file without any interaction from the user? Image3 shows the properties of the XMLport.
Thanks!
I have an XMLport that exports a report to a CSV file. No issues there. When the XMLport runs, I would like the file to be saved to the export folder without the Export File Dialog box opening and asking: “Do you want to open or save this file?” See Image1. There is a checkbox that I can uncheck “Always ask before opening this type of file.” But when I uncheck it,the Export dialog box still opens up, see Image2, with the correct export folder automatically selected, but I still need to click the Save button.
How can I get the XMLport to Save a file without any interaction from the user? Image3 shows the properties of the XMLport.
Thanks!
0
Best Answer
-
You can create a report without any DataItem , with the propierties UseRequestPage = No and ProcessingOnly = Yes
And put thos code in the
OnPreReport()
// FileMgt codeunit 419
// FileName Text
// OutFile File
// OutS OutStream
// Xmlp your XMLPort
FileName := FileMgt.ServerTempFileName('CSV');
OutFile.CREATE(FileName);
OutFile.CREATEOUTSTREAM(OutS);
Xmlp.FILENAME(FileName);
Xmlp.SETDESTINATION(OutS);
Xmlp.EXPORT;
OutFile.CLOSE;
FileMgt.DownloadToFile(FileName, 'c:\output\ExportFile.csv');
And execute the report.
You can create a codeunit too with the same code if you like it more.
Regards.1
Answers
-
HEy Vimo,
Do it this way, it will help you for sure.
https://msdn.microsoft.com/en-us/library/hh166529(v=nav.90).aspx
dynamicsuser.net/nav/f/106/t/72355
dynamicsuser.net/nav/f/106/t/69123
Thanks
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/1 -
You can create a report without any DataItem , with the propierties UseRequestPage = No and ProcessingOnly = Yes
And put thos code in the
OnPreReport()
// FileMgt codeunit 419
// FileName Text
// OutFile File
// OutS OutStream
// Xmlp your XMLPort
FileName := FileMgt.ServerTempFileName('CSV');
OutFile.CREATE(FileName);
OutFile.CREATEOUTSTREAM(OutS);
Xmlp.FILENAME(FileName);
Xmlp.SETDESTINATION(OutS);
Xmlp.EXPORT;
OutFile.CLOSE;
FileMgt.DownloadToFile(FileName, 'c:\output\ExportFile.csv');
And execute the report.
You can create a codeunit too with the same code if you like it more.
Regards.1 -
Thank you so much ftornero!!! This worked beautifully. I added the code to my codeunit and it exported the file to the folder without any dialog box opening up. You are the best!
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions