Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Answered

How to Store File like .txt,.pdf in table in NAV 2018

Posted on by 240

Hi, All

I am trying to store it .txt,.pdf file in Item Card. So I Create One Command button to Browse the File using the following Code.

Item.GET('C00001');
SelectedFile := FileMgt.OpenFileDialog('NAV File Browser','*.txt','');
Item.FileText := SelectedFile ;     
Item.MODIFY;
MESSAGE('You selected %1', SelectedFile);

But. I didn't Find out the way how to store the file in Table Field. Because the issue is that if that file is deleted from that location so a user can not find the file. 

So Help me out that Issue.

Thanks in Advance

  • Verified answer
    Suresh Kulla Profile Picture
    Suresh Kulla 43,745 on at
    RE: How to Store File like .txt,.pdf in table in NAV 2018

    The way you coded right now get you the file name but if you want to store the actual file then you need to use the Blob field and use the code something like below. By this way, you are storing the actual content

    Check the codeunit 134

    FileName := FileManagement.BLOBImportWithFilter(TempBlob,'Upload File',FileName,STRSUBSTNO(FileDialogTxt,FilterTxt),"*.txt;*.pdf;");
    Item.Content := TempBlob.Blob;

    Item.Modify

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans