{Scenarios} – Registering plugins when a user is added to Team in Microsoft Dynamics CRM.

Well if you are reading this topic and thinking that there is already a whole lot of information available on how to register a plugin when a user is added to a team, then why this post again. Yes you are right. But I could see there is some incomplete information in many of the blog posts. So let’s see the complete picture. Many of you might already be aware of this. However still posting because it might be of some help.


Ok let’s start then. Say we register a plugin on the AddMembers message for the team entity. Going by SDK documentation, this should fire when we add a user to a team or when a team is assigned to a user. As you can see, I have regsitered a plugin for the AddMembers message for the team entity.


However when I manually go ahead and add a member to a team in CRM or when I add a existing team to a user through CRM Application, strangely the plugin does not fire. Search on this and you would find lot of very good blog posts that to handle this, register your plugin in the Associate message as shown in the below screenshot. And in the code handle the primary entity and the related entity.



Well so far so good and you would have surely come across this if you had ever to register a plugin when a user is added to a team. So does this mean that plugin on “AddMembers” does not fire under any circumstances. That’s not the case. But it fires under a different scenario.

Many a times you need to add a user to a team programmatically using the “AddMembersTeamRequest”. So when this request is executed, the associate message is not fired. instead this time the plugin registered on the “AddMembers” gets fired. Below I have written a code which associates a user to a team.



Below is the screenshot of what I get in the debugger of the registered plugin.



So register in the “associate” message when you are adding a user to a team from the CRM application. However if you are adding a user to a team programatically, register a plugin on the AddMembers message because associate won’t fire in that case.


Hope this helps!

Author: Debajit

I am a Dynamics CRM Most Valuable Professional (MVP) with 12 years of experience in Microsoft .NET Technologies and 9 years of dedicated experience in Microsoft Dynamics CRM. I have worked with companies like Microsoft, SanDisk, PwC, TMF Group and have extensive experience of implementing complex CRM solutions from both offshore and client side. Currently the face of XrmForYou.com with significant experience in delivering corporate training on Dynamics CRM and have already delivered multiple projects to client through XrmForYou.com Author of multiple tools on codeplex including the 'Role Based Views' and 'CRM-Sharepoint Metadata manager & Attachment Extractor' which are available for commercial use under XrmForYou.com For consulting/ training, drop me a note at info@xrmforyou.com or visit our website www.xrmforyou.com

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s