Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

How to de-reference Media fields?

Posted on by 171
Hello folk!
This is my first time playing around with Media Type instead of blog and I'm facing a bit of a challenge.
I have two tables - Location Master with a Media Type field storing QR Codes and Sales Header where the QR Code is to be referenced.
When the Location is set on the Sales Header, I can use the Validate trigger to set the /Location QR Code/ field of the Sales Header by assigning the /QR Code/ of the Location record.
However, when the time comes to change the Location Code on the Sales Header and I try to de-reference the /Location QR Code/ of the Sales Header, I end up deleting the QR Code's data from the main /Location/ record itself.
If I use the Import/Export stream methods that creates additional tenant media records which uses up more space than necessary.
I read in the Microsoft docs that as long as the Tenant Media record is being referenced somewhere, it does not get deleted so I was hoping that would work out.
Also, this blog here suggests that when we assign a Media field to another, then both reference the same record in the Tenant Media table.
I want to know how to dereference one of them.
Any direction is highly appreciated!
Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 64,622 Super User on at
    How to de-reference Media fields?
    If it is MediaSet Data Type, you can try the following mehtod, but Media data type does not. . . .
    MediaSet.Remove(Guid) Method
  • RahulBansode Profile Picture
    RahulBansode 171 on at
    How to de-reference Media fields?
    Hi Yun Zhu,
     
    I have tried the clear(Rec.MediaField) function as well however it ends up deleting the media from both the tables i.e. the Tenant Media record itself is deleted.
    I also tried reassigning it to a uninitialized media field (Rec.MediaField = TempRec.MediaField) but that also erased the data from both the tables which is rather unexpected.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 64,622 Super User on at
    How to de-reference Media fields?
    Hi, have you tried using Clear method?
    For example,
    Clear(Rec.Picture);
     
    Hope this helps.
    Thanks.
    ZHU
     
  • RahulBansode Profile Picture
    RahulBansode 171 on at
    How to de-reference Media fields?
    Hi there!
    My goal is to prevent the deletion of the Tenant Media record and simply de-reference it from one of the records without affecting the other,
    Orphaned Media records are not really relevant here.
  • Suggested answer
    gdrenteria Profile Picture
    gdrenteria 5,353 Super User on at
    How to de-reference Media fields?

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,768 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,985 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans