Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Unanswered

How to automatically delete image from Azure Blob Storage while deleting attachment

(0) ShareShare
ReportReport
Posted on by 459

Hi Folks,

I was trying to delete unused images from Azure Blob Storage which is coming from D365 FO as a attachment.

When a new attachment is done in D365 FO, the same image will be uploaded in blob Storage. Now I want to delete the Attachment from D365 FO through code and it should automatically delete the file from Blob storage.

but it is not working. Could you please help me on this.

please let me know if some information is required from my end.

  • Martin Dráb Profile Picture
    Martin Dráb 230,934 Most Valuable Professional on at
    RE: How to automatically delete image from Azure Blob Storage while deleting attachment

    As I said, I would debug delete() method to see what's going on there. Collection information is better than guessing. By the way, I believe that enabling "Deferred deletion enabled" goes against your requirements. Again, you can see the impact of this parameter when looking into delete().

  • D365FO Avatar Profile Picture
    D365FO Avatar 459 on at
    RE: How to automatically delete image from Azure Blob Storage while deleting attachment

         if(isExist)
                    {
                       ttsbegin;
                    
                        if(docuref.validateDelete())
                        {
                            docuRef.delete();
                        }
                        else
                        {
                            ttsabort;
                        }                    
    
                        ttscommit;
                    } 

    pastedimage1680275304605v1.png

    Although written a class with looping for DocuRef and at last calling DocuRef.Delete().

    But still it not worked than I tried to update some Document management parameters 

    1. Enable checkbox "Deferred deletion enabled" and update 0 in "Number of days to defer deletion"

    2. Disabled checkbox "Enable Document History" 

    But still it is not working. Could you please let me know if I'm wrong somewhere.

  • Martin Dráb Profile Picture
    Martin Dráb 230,934 Most Valuable Professional on at
    RE: How to automatically delete image from Azure Blob Storage while deleting attachment

    I think that document management supports this feature, if enabled.

    I recommend debugging DocuRef.delete() - it'll give you more information than mere "it's not working".

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,111 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,934 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans