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)

How to delete all attributes in context of plugin?

(0) ShareShare
ReportReport
Posted on by

I want to prevent the update on an entity. So I am planning to write plugin on pre-operation of that entity, where I want to remove all context attributes. so that it will not be updated. 

How can it be done?

Or.. is there any other way to prevent update on an entity?

Please help me...

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Rawish Kumar Profile Picture
    13,758 on at

    Ancy,

    Do you not want this to completely be update/saved or you want specific fields to not update?

  • Guido Preite Profile Picture
    54,086 Moderator on at

    which is your exact requirement?

  • Ancy Profile Picture
    on at

    Thank you Rawish for a quick response. Yes, I don't want any fields in the context to get updated.

  • Ancy Profile Picture
    on at

    Thank you Guido for a quick response.

    The requirement is:-

    The OOB Merge functionality of dynamic CRM is copying all the informations from child record  in the master record and is setting activities and related records of child record to master record.

    But I want  only the activities to get copied.

    So, I am thinking of clearing the context data in Merge pre-operation.

    Is the approach correct? Any suggestions??

  • Suggested answer
    tw0sh3ds Profile Picture
    5,600 on at

    Just like I told you already in another question, you have to make a plugin for related entity (which parent entity will be updated during merge) not the merge operation itself. So let's say you have Account which you merge and want to prevent Contacts from being moved to the new Account. You create a plugin Pre-Update of contact which will fire on update of parentcustomerid field. In the plugin you simply check if this update comes from Merge operation (by checking the parent context) and if yes, you simply remove attribute parentcustomerid from Target.

  • Ancy Profile Picture
    on at

    Yes Thank you. I have thought about it. But in the situation as I described above.. I will be having many related records. Because the child record can have any number of related activities and related records. So, how may plugins will I have to write is uncertain... and thus this approach is not feasible as far as I analysed.

    Please correct me if I am wrong.

    Thus I was looking for an approach to prevent it from the merge message of the entity itself.

  • Suggested answer
    tw0sh3ds Profile Picture
    5,600 on at

    For some of the entitites you should be able to configure your relationship as Cascading and simply choose the Merge option to "None", but for some system relationships this is not possible and you will have to write plugin. If done properly you can have only one plugin, you will just have to register multiple plugin steps in Plugin Registration Tool

  • Verified answer
    Ancy Profile Picture
    on at

    Thank you everyone for your replies.

    Finally I have taken an approach to write Pre and Post operation plugin on merge message of master entity.

    On Pre merge operation I have retrieved collection of all related entities and context data. Stored it in a shared variable. And finally used it in post merge operation to revert the changes done by OOB Merge.

    And it worked!!

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