Classes and interfaces

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

Kipon.Xrm.Attributes.RelationshipAttribute

RelationshipAttribute is a specialized IfAttribute, and us used to filter Associate and Disassociate requests to only be called for specific relationship.

The Associate and Disassociate standard actions of the Dynamics 365 CE platform are unbound. This means that a plugin listening to these actions will be called whenever M:M relationsship entities are created or deleted. To avoid having to filter directly in your plugincode for the relationship you are interested in, you can decorate your plugin step method with this attribute.


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 plugin code is listening for the Associate and Disassociate action in pre stage, however these method are only called if the relationsship being created it betweeen a systemuser and a role.

To understand the input parameter of this example, take a look the IAssociateRequest.

© Kipon ApS 2020, 2021, 2022, 2023. 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.