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 :
Microsoft Dynamics NAV (Archived)

Save .txt File

(0) ShareShare
ReportReport
Posted on by 2,560

Hi All,

How can I save the text file instead of prefix the file name (refer to picture below) in report? Such as let user to save their own .txt file in the particular folder location or prompt a window to request for "Open" , "Save" or "Cancel"?

Best Regards,

Vanessa

*This post is locked for comments

I have the same question (0)
  • Verified answer
    jcastro Profile Picture
    2,245 on at

    Here you go :-)


    Variable:

    FileMgt - Codeunit - File management

    DestinationFile - Text1024


    Code:

    DestinationFile := FileMgt.SaveFileDialog('Window Title','file.txt','Text files (*.txt)|(*.txt)');

    MESSAGE(DestinationFile);

    Also, you might want to check this out:
    blogs.msdn.com/.../nav-pattern-of-the-week-silent-file-upload-and-download.aspx

  • Vanessa Shin Profile Picture
    2,560 on at

    Hi Jose,

    Thanks for your reply.

    By the way, I met an error below when run the report. Am I getting anything wrong?

    pic1.png

    Enclosed herewith the screenshot of code and layout. Please advice.

    a) pic2.png
    b) pic3.png
    c) pic4.png
    d)

    Vanessa

  • Suggested answer
    jcastro Profile Picture
    2,245 on at

    When the file dialog opens, where do you choose to store the file (path)?

  • Vanessa Shin Profile Picture
    2,560 on at

    I tried save in Local Disk C, D & desktop. Or should I create new folder and store in?

  • Vanessa Shin Profile Picture
    2,560 on at

    Hi Jose,

    I solved it successfully. Thanks again.

  • Suggested answer
    jcastro Profile Picture
    2,245 on at

    Glad to hear it! What was causing the error? So if someone else faces the same issue they have somewhere to look :-) 

  • Vanessa Shin Profile Picture
    2,560 on at

    Hi Jose,

    If I want to do it on NAV 5, then which codeunit should I use instead of codeunit File Management?

  • Suggested answer
    4BzSoftware Profile Picture
    6,073 on at

    Hi Vanessa,

    NAV 2013 is 3 tiers and needs codeunit File Management to handle files between Server and Client:

    - Create files at Server.

    - Download files to Client.

    - Upload files from Client.

    NAV 2, 3, 4, 5, 6 are 2 tiers and file is handled at Client directly. As your request, you can use codeunit Common Dialog Management.

  • Vanessa Shin Profile Picture
    2,560 on at

    Hi,

    But Common Dialog Management codeunit only has OpenFile function. Hence, it still can use like File Management?

  • Verified answer
    4BzSoftware Profile Picture
    6,073 on at

    Hi Vanessa,

    For NAV 2013 to 2015, this video is very useful http://msdn.microsoft.com/en-us/dynamics/nav/dn647267

    For NAV Classic Client (version 2 to 6), Common Dialog Management codeunit helps you get the file name. It is both Open file or Save file dialog, depending on last parameter (0 is Open, 1 is Save):

    lTxt_FileName := lCoU_ComDlg.OpenFile('Save Text File', '', 1, 'Text file (*.txt)|*.txt', 1);

    IF (lTxt_FileName = '') THEN

     EXIT;

    Then follow below link to save your text:

    msdn.microsoft.com/.../dd301078.aspx

    Use user selected file name as MyHTMLFile.CREATE(lTxt_FileName);

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 > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans