Announcements
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.
Hello,
I have just tried in my online instance and it works as expected.
I have register plugin steps for Associate & Disassociate as below-
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-
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/
Hello,
If you wanted Newplugin to trigger after Oldplugin , then set the execution order of your Newplugin to 2. If not , then vise versa.
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156