Copy MediaSet from company to another company

LefteyedLefteyed Posts: 38Member
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?

Best Answers

  • LefteyedLefteyed Posts: 38
    edited 2017-10-18 Accepted Answer
    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:

    TenantMedia."Company Name" := '';
    IF TenantMediaSet.GET(Item2.Picture.MEDIAID,Item1.Picture.ITEM(1)) THEN
    TenantMediaSet."Company Name" := 'CRONUS Danmark';

    We had it working in CU7, but checked the list and in CU5 there is this:

    206147 The Mediaset Item function does not work.


  • Slawek_GuzekSlawek_Guzek Posts: 1,454Member
    Slawek Guzek
    Poszukuje programistow znajacych Microsoft Dynamics NAV
  • LefteyedLefteyed Posts: 38Member
    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.
  • Slawek_GuzekSlawek_Guzek Posts: 1,454Member
    I guess your answer is that the TRANSFERFIELDS also does not work.
    Slawek Guzek
    Poszukuje programistow znajacych Microsoft Dynamics NAV
  • JuhlJuhl Posts: 523Member
    MediaSet is only a collection of Media.
    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.
    Follow me on my blog
  • LefteyedLefteyed Posts: 38Member
    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()
    ExportPath := TEMPORARYPATH + "No." + FORMAT(Picture.MEDIAID);
    ToFile := STRSUBSTNO('%1 %2.jpg',"No.",Description);
    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.

  • JuhlJuhl Posts: 523Member
    Create a picture table with a Media field, make the table per database.
    Follow me on my blog
Sign In or Register to comment.