After spending some time with those tables we found out that it is possible to use the same picture/media in different companies.
Table 2000000184 Tenant Media
Here the picture is saved in a blob field.
There are also a company name. This name is the owner of the blob field. If we make the field empty then all companies are able to use then picture.
Table 2000000183 Tenant Media Set
It contains a record for every connection between for instance item and picture.
Here the company must be changed so that the item and company is matching.
When exporting picture from one item (company 1) and inserting it to another item (company 2) and we used item2.changecompany this was not enough.
The record in this table sets the company name to be the same as item1.
It seems to be an issue with NAV2017 CU3 with Item.Picture.Item(index) as it creates an error (Compiling af collection xxxxx. .dll failed)
Therefore we didn't get it in the first place, but after trying with NAV2017 CU7 we got this working:
Item2.Picture.INSERT(Item1.Picture.ITEM(1));
Item2.MODIFY;
TenantMedia.GET(Item1.Picture.ITEM(1));
TenantMedia."Company Name" := '';
TenantMedia.MODIFY;
IF TenantMediaSet.GET(Item2.Picture.MEDIAID,Item1.Picture.ITEM(1)) THEN
BEGIN
TenantMediaSet."Company Name" := 'CRONUS Danmark';
TenantMediaSet.MODIFY;
END;
EDIT:
We had it working in CU7, but checked the list and in CU5 there is this:
So even as my picture is bmp, it will save it as jpg.
I was also looking at MediaSet table and Media.
But found out that the picture is saved in Table 2000000184 Tenant Media.
It seems like that I need to save the picture 4 times due to 4 companies. There should be a smarter way of doing this. Save it ones, then make Ref to the picture. And if no ref to a picture, then it should be deleted.
After spending some time with those tables we found out that it is possible to use the same picture/media in different companies.
Table 2000000184 Tenant Media
Here the picture is saved in a blob field.
There are also a company name. This name is the owner of the blob field. If we make the field empty then all companies are able to use then picture.
Table 2000000183 Tenant Media Set
It contains a record for every connection between for instance item and picture.
Here the company must be changed so that the item and company is matching.
When exporting picture from one item (company 1) and inserting it to another item (company 2) and we used item2.changecompany this was not enough.
The record in this table sets the company name to be the same as item1.
It seems to be an issue with NAV2017 CU3 with Item.Picture.Item(index) as it creates an error (Compiling af collection xxxxx. .dll failed)
Therefore we didn't get it in the first place, but after trying with NAV2017 CU7 we got this working:
Item2.Picture.INSERT(Item1.Picture.ITEM(1));
Item2.MODIFY;
TenantMedia.GET(Item1.Picture.ITEM(1));
TenantMedia."Company Name" := '';
TenantMedia.MODIFY;
IF TenantMediaSet.GET(Item2.Picture.MEDIAID,Item1.Picture.ITEM(1)) THEN
BEGIN
TenantMediaSet."Company Name" := 'CRONUS Danmark';
TenantMediaSet.MODIFY;
END;
EDIT:
We had it working in CU7, but checked the list and in CU5 there is this:
Answers
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Therefore CALCFIELDS is not allowed.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Maybe this information could be useful for you
https://msdn.microsoft.com/en-us/dynamics-nav/working-with-media-on-records
I didn't look through NAV 2017, but hope, that MediaSet is a good step to improve store management of external files in db.
Yury
Media is stored in a separate table, where the blob is stored.
I always create a Media type field, as MediaSet can’t clean up Media. So old files are left with no parent.
You can stream Media in and out.
"Funny" thing is that the code is like:
ExportFile - OnAction()
NameValueBuffer.DELETEALL;
ExportPath := TEMPORARYPATH + "No." + FORMAT(Picture.MEDIAID);
Picture.EXPORTFILE(ExportPath);
FileManagement.GetServerDirectoryFilesList(TempNameValueBuffer,TEMPORARYPATH);
TempNameValueBuffer.SETFILTER(Name,STRSUBSTNO('%1*',ExportPath));
TempNameValueBuffer.FINDFIRST;
ToFile := STRSUBSTNO('%1 %2.jpg',"No.",Description);
DOWNLOAD(TempNameValueBuffer.Name,DownloadImageTxt,'','',ToFile);
IF FileManagement.DeleteServerFile(TempNameValueBuffer.Name) THEN;
So even as my picture is bmp, it will save it as jpg.
I was also looking at MediaSet table and Media.
But found out that the picture is saved in Table 2000000184 Tenant Media.
It seems like that I need to save the picture 4 times due to 4 companies. There should be a smarter way of doing this. Save it ones, then make Ref to the picture. And if no ref to a picture, then it should be deleted.
Table 2000000184 Tenant Media
Here the picture is saved in a blob field.
There are also a company name. This name is the owner of the blob field. If we make the field empty then all companies are able to use then picture.
Table 2000000183 Tenant Media Set
It contains a record for every connection between for instance item and picture.
Here the company must be changed so that the item and company is matching.
When exporting picture from one item (company 1) and inserting it to another item (company 2) and we used item2.changecompany this was not enough.
The record in this table sets the company name to be the same as item1.
It seems to be an issue with NAV2017 CU3 with Item.Picture.Item(index) as it creates an error (Compiling af collection xxxxx. .dll failed)
Therefore we didn't get it in the first place, but after trying with NAV2017 CU7 we got this working:
Item2.Picture.INSERT(Item1.Picture.ITEM(1));
Item2.MODIFY;
TenantMedia.GET(Item1.Picture.ITEM(1));
TenantMedia."Company Name" := '';
TenantMedia.MODIFY;
IF TenantMediaSet.GET(Item2.Picture.MEDIAID,Item1.Picture.ITEM(1)) THEN
BEGIN
TenantMediaSet."Company Name" := 'CRONUS Danmark';
TenantMediaSet.MODIFY;
END;
EDIT:
We had it working in CU7, but checked the list and in CU5 there is this:
206147 The Mediaset Item function does not work.