Copy MediaSet from company to another company
Lefteyed
Member Posts: 43
Hi guys
Anyone worked with MediaSet and transfer/Copy from one company to another?
I have a picture on Item that I want to copy to all companies. But cant use NewRec.Picture := OldRec.Picture
Any ideas?
Anyone worked with MediaSet and transfer/Copy from one company to another?
I have a picture on Item that I want to copy to all companies. But cant use NewRec.Picture := OldRec.Picture
Any ideas?
0
Best Answers
-
Hi, Lefteyed
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.Regards,
Yury5 -
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:
206147 The Mediaset Item function does not work.1
Answers
-
Have you tried CALCFIELDS + TRANSFERFIELDS ?Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Calcfields is okay on BLOB, but as in NAV2017 and newer it is MediaSet and then it is not flowfield.
Therefore CALCFIELDS is not allowed.0 -
I guess your answer is that the TRANSFERFIELDS also does not work.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
Hi, Lefteyed
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.Regards,
Yury5 -
I was looking at page 31 as it has picture in a factbox where you can export the picture.
"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.
0 -
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:
206147 The Mediaset Item function does not work.1
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions

