Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Retrieve attributes from a record with a plugin triggered on Delete record event

Posted on by 150

Hello everyone,

I am implementing a plugin which get triggered on delete event from  Order Line entity. In my scenario, i created relationships between Order Lines and Product entities and between Order Line and Warehouse entities.

Once i delete the record, i would like to retrieve the value of both lookup fields from the Order Line record. One lookup field points to the Product related, and the other lookup field points to the warehouse related.

Once i get these both entity references, i update the value for a third-part entity Product Inventory based on the value of these both entity references.

The plugin is Async Post

public void Run()
{
Entity deletedSalesOrderProduct = service.Retrieve(Att.SalesOrderDetail.logicalName, entityReference.Id, Att.SalesOrderDetail.columns);

/* Other functionality */

}

By any reason, i  cannot access to the record and i have the error "The requested record was not found or you do not have sufficent permissions to view it "

Thanks in advance!

Kind regards.

*This post is locked for comments

  • Jorge Gomez Profile Picture
    Jorge Gomez 150 on at
    RE: Retrieve attributes from a record with a plugin triggered on Delete record event

    Thanks very much Vikas,

    It works now, your replies gave me the solution!

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve attributes from a record with a plugin triggered on Delete record event

    You need to run your plugin before the database operation is executed. So registering it in pre operation is enough I guess.

  • Jorge Gomez Profile Picture
    Jorge Gomez 150 on at
    RE: Retrieve attributes from a record with a plugin triggered on Delete record event

    Do you mean pre-operation or pre-validation?

    Kind regards.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve attributes from a record with a plugin triggered on Delete record event

    You need to register your plugin on pre event. Right now you have registered it on post event so the record does not exists in DB once deleted.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans