Skip to main content

Notifications

Announcements

No record found.

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!
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,942 Super User 2024 Season 2 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 75,942 Super User 2024 Season 2 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 13,116 Most Valuable Professional on at
    How to de-reference Media fields?

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,784 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans