Reputation: 39250
This baffles me big time. I've set up a plugin that executes the exact same call (I'm logging the strings and GUIDs sent in and I see they are exact the same) on update and delete of entity Alpha.
The action in the method called is to count the number of instances of another entity, Beta, whose lookup points to the created/deleted instance.
Now, now - everybody sights here and thinks "the dumb donkey forgot to register the deletion on pre-operation". But no. I thought so too but it's on pre-operation so the instance is still in existence and the lookup is connected to it (isn't it?!) so it must be something else.
Now, now - everybody sights again and thinks "the dumb donkey confused the ID in the target (for creation) and ID for the preimage (for delete)". But no. I'm making that distinction and I actually log the values sent in, so I can see that the GUID is exactly the same.
After seven hours of debugging I'm concluding that I'm not able to break it. Too annoyed, or something. Anybody with a good idea how to approach it and what I'm missing?
(There'll be a bounty on this for whomever gets me going but I can't wait for two days.)
Upvotes: 2
Views: 74
Reputation: 2087
If you are running a plugin on the pre-operation event of the Delete message, one thing to note is that by that time CRM has already disassociated the record in context with any child records. Therefore if you need to query for any child records relating to that record, nothing will return from your query.
A way around this would be to register your plugin in the pre-validation event.
Upvotes: 3