web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

How to de-reference Media fields?

(1) ShareShare
ReportReport
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!
I have the same question (0)
  • Suggested answer
    Gerardo Rentería García Profile Picture
    25,225 Most Valuable Professional on at
  • RahulBansode Profile Picture
    171 on at
    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
    YUN ZHU Profile Picture
    95,597 Super User 2025 Season 2 on at
    Hi, have you tried using Clear method?
    For example,
    Clear(Rec.Picture);
     
    Hope this helps.
    Thanks.
    ZHU
     
  • RahulBansode Profile Picture
    171 on at
    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
    95,597 Super User 2025 Season 2 on at
    If it is MediaSet Data Type, you can try the following mehtod, but Media data type does not. . . .
    MediaSet.Remove(Guid) Method

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,785

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,007 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 948 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans