This post comes from a request I’ve received today regarding a problem on opening an attachment to a Purchase Order in NAV.
As you know, Microsoft Dynamics NAV permits you to “attach” links to external documents to a NAV entity. If I have for example a Purchase Order and I want to attach a document that comes from my vendor (for example a PDF), I can click on Links, select New and then select a file to attach to the Purchase Order:
When selected, NAV stores a link to this file in the Record Link table (ID 2000000068). The file is not physically stored on the database as a BLOB. Unfortunately, as you can see in the following picture, if the attach is not previously stored in a central repository (file server) the link can point to an address that will be unreachable to other NAV users (in this sample, it points to the desktop of my client):
This is not well managed I think. Normally, if you attach an external document to an NAV entity, I would like that this document will be available to all other users and I would like that this document will be archived on a file share (or on a central repository for the company). In every my NAV databases, usually I have this little customization:
In the Company Information table, I have a File Storage Path field that points to the network address of a centralized file share.
Then, I have a custom codeunit (Record Link Management) that has a function called HandleRecordLink defined as follows:
In this function, we have these local variables:
The code to handle the Record Link is as follow:
Here, we create a file name that will be unique (obviously, here the rules can be defined as you want) and then the local file is copyed from the client to the network share. Then, the Record Link entry is updated with the new link. In this way, all the attachments are handled in a centralized way (security, backup and so on) and they will be accessible to everyone with the appropriate permissions (no more broken or local links).
Easy and useful… 🙂
P.S. Links (documents) can be stored also on Sharepoint or on Azure Storage…