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 :
Microsoft Dynamics CRM (Archived)

Plugin on delete step

(1) ShareShare
ReportReport
Posted on by

Hello CRM Developers,

i have an issue with my plugin 

i have a custom entity that has a grid view in the form, the relationship is 1:N, a plugin that runs on the delete of the related entity works fine but when i have more than 1 record, once the last record gets deleted, the plugin sees the "Target"  as an EntityReference and not an entity, so the code doesn't run

please note that the it only fails when i have 1 record in my grid 

please help 

thanks 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    you just need to check if Context.InputParameters["Target"] is an EntityReference.

    If you need to retrieve the record you can use the Id and LogicalName property of the EntityReference together with a Retrieve to get the actual record fields.

  • Community Member Profile Picture
    on at

    Thanks Guido,

    so i need to check first if target is an entity reference, and then get the id from the target, so is this the record id??

  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    yes,

    you need to cast the Target to an EntityReference, for example:

    EntityReference recordRef = (EntityReference)Context.InputParameters["Target"];

    in this way recordRef.Id contains the Guid of the record, recordRef.LogicalName is the logical name of the record

  • Community Member Profile Picture
    on at

    Thanks Guido

  • Community Member Profile Picture
    on at

    Hello Guido,

    i have tried this, i get this error :

    Record Is Unavailable

    The requested record was not found or you do not have sufficient permissions to view it

    but the record does exist and the guid, logical Name, columnSet are correct

    please help

  • Community Member Profile Picture
    on at

    Please note that i am working with an admin user

  • Guido Preite Profile Picture
    54,086 Moderator on at

    what is doing this plugin?

    how you registered it? synchronous/asynchronous, prevalidation,preoperation,postoperation?

  • Community Member Profile Picture
    on at

    Thanks Guido,

    you gave me a clue, i was registering my plugin on postoperation, which is not correct

  • Community Member Profile Picture
    on at

    Please register the plugin in PreOperation, Then you won't get an error..

    Thank you.

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans