web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Does IOrganizationService.(Dis)Associate not trigger (Dis)Associate plugins?

(0) ShareShare
ReportReport
Posted on by 15

Hello,

I have two entities, Events and Missions that have a N:N relationship. I registered a plugin (let's call it NewPlugin) to run on both associate and disassociate between these two entities. NewPlugin works just fine when a user manually associates a Mission to an Event via a subgrid, and same when disassociating.

The issue is that we also have OldPlugin that, among other things, can potentially associate several Missions to an Event at once via the IOrganizationService.Associate method. Unfortunately, the associations made via OldPlugin don't appear to trigger NewPlugin at all. I have some tracing in NewPlugin, but I'm not seeing any trace logs being created after OldPlugin runs, which tells me that NewPlugin doesn't get triggered at all.

Is this an instance of Microsoft half-assing their implementation of the (dis)associate messages/plugins, or am I doing something stupid? Would I be better off swapping my plugin to run on an Event's update instead?

Note: we're running version 1612 (9.0.32.3) on-premises if it helps. 

I have the same question (0)
  • Ahmed Al-Khatib Profile Picture
    5 on at

    Hello,

    If you wanted Newplugin to trigger after Oldplugin , then set the execution order of your Newplugin to 2. If not , then vise versa.

  • Suggested answer
    Bipin D365 Profile Picture
    28,985 Moderator on at

    Hello,

    I have just tried in my online instance and it works as expected.

    I have register plugin steps for Associate & Disassociate as below-

    CR1.JPG

    I have used below code from C# to associate & disassociate records-

     public static void AssignSecurityRole(Guid guidSystemUserId, Guid guidSecurityRoleId, IOrganizationService crmService)
            {
                
                // Create new Associate Request object for creating a N:N relationsip between User and Security
                AssociateRequest objAssociateRequest = new AssociateRequest();
                // Create related entity reference object for associating relationship
                // In this case we SystemUser entity reference  
                objAssociateRequest.RelatedEntities = new EntityReferenceCollection();
                objAssociateRequest.RelatedEntities.Add(new EntityReference("systemuser", guidSystemUserId));
                // Create new Relationship object for System User & Security Role entity schema and assigning it 
                // to request relationship property
                objAssociateRequest.Relationship = new Relationship("systemuserroles_association");
                // Create target entity reference object for associating relationship
                objAssociateRequest.Target = new EntityReference("role", guidSecurityRoleId);
                // Passing AssosiateRequest object to Crm Service Execute method for assigning Security Role to User
                crmService.Execute(objAssociateRequest);
            }
    
            public static void RemoveSecurityRole(Guid guidSystemUserId, Guid guidSecurityRoleId, IOrganizationService crmService)
            {
    
                // Create new Associate Request object for creating a N:N relationsip between User and Security
                DisassociateRequest objAssociateRequest = new DisassociateRequest();
                // Create related entity reference object for associating relationship
                // In this case we SystemUser entity reference  
                objAssociateRequest.RelatedEntities = new EntityReferenceCollection();
                objAssociateRequest.RelatedEntities.Add(new EntityReference("systemuser", guidSystemUserId));
                // Create new Relationship object for System User & Security Role entity schema and assigning it 
                // to request relationship property
                objAssociateRequest.Relationship = new Relationship("systemuserroles_association");
                // Create target entity reference object for associating relationship
                objAssociateRequest.Target = new EntityReference("role", guidSecurityRoleId);
                // Passing AssosiateRequest object to Crm Service Execute method for assigning Security Role to User
                crmService.Execute(objAssociateRequest);
            }

    See below image for plugin trace logs-

    CR62.PNG

    I don't have access to On-premise instance. I would recommend to verify these things to check if all setup is correct on your instance.

    If it still does not work, I would ask you to lodge Microsoft support ticket.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Hamza H Profile Picture

Hamza H 142 Super User 2026 Season 1

#2
Nagaraju_Matta Profile Picture

Nagaraju_Matta 128

#3
ManoVerse Profile Picture

ManoVerse 127 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans