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…
Nice job !
LikeLike
Hi. Is it possible that an attached link is deleted without actually deleting the data?
LikeLike
As standard yes, if you delete a record link the file is not deleted (and it’s correct!). If you want to also remove the file, just handle the OnAfterDelete event.
LikeLike
Is it possible to do this with the web client?
LikeLike
Yes you can upload a file via stream and save it to Azure Storage or other.
LikeLike
Thanks it was very helpfull.
In my case, i am loading the file to a network share and it woks nice.
My problem is when we use the webclient, it is not generating the links correctly. For example:
In desktop client: X:\Folder1\folder2\14122020 – ABC.pdf (works ok)
In web client : http://14122020%20-%20ABC.pdf/
Can you help me, please?
LikeLike