Classes and interfaces

In this section, each class and interface of the concept will be explained in details.

Kipon.Xrm.Actions.IAssociateRequest

Kipon.Xrm.Actions.IAssociateRequest is the plugin step parameter for a plugin listening for associate or disassociate requests.

  • Microsoft.Xrm.Sdk.Relationship Relationship: Get the relation, triggering the event
  • Microsoft.Xrm.Sdk.EntityReference Target: Get the reference of the target that are associated/disassociated
  • Microsoft.Xrm.Sdk.EntityReferenceCollection RelatedEntities: The list of entities being associated/disassociated to the target
  • AssociateType Type: Associate or Disassociate

You can write plugins that listen to the event that an entity is being associated/disassociated with another entity in a M:M relation between the entities. To get easy access to the detail information about the associate request, inject this interface into you plugin method.


namespace Kipon.PluginExample.Plugins.Associate
{
    public class AssociateUserRolePlugin : Kipon.Xrm.BasePlugin
    {
        [Kipon.Xrm.Attributes.Relationship("systemuserroles_association")]
        public void OnPreAssociate(Kipon.Xrm.Actions.IAssociateRequest request)
        {
            // do something when users and roles are associated
        }

        [Kipon.Xrm.Attributes.Relationship("systemuserroles_association")]
        public void OnPreDisassociate(Kipon.Xrm.Actions.IAssociateRequest request)
        {
            // do something when users and roles are disassociated
        }
    }
}

Above is an example of a plugin listening for both associate and disassociate event. The event is triggerede on pre (before the database is updated). Also notis the Relationship decorator on the two step methods: OnPreAssociate an OnPreDisassociate. This decorator is ensuring that these method will only be called if the Relationship is between the systemuser and the role entity.

The associate/disassociate message is an unbound standard action, and plugin listening on the associate and disassociate method will be called for any M:M association. By adding the Relationship decorator, we limit call to our method to the systemuserroles_association M:M relationship only.

© Kipon ApS 2020, 2021, 2022, 2023, 2024. All content on the page is the property of Kipon ApS. Any republish or copy of this content is a violation. The content of this site is NOT open source, and cannot be copied, republished or used in any context without explcit permission from the owner.