Event on Many to Many Relationship (N:N) in CRM 4
Microsoft Dynamics CRM 4 does not expose any event when records are associated through N:N relationship. So if you want to perform some function when a record is associated to another record in N:N relationship, CRM simply excuses and you have to look into hacks and unsupported solutions.
There is a cool hack by Aaron at http://consulting.ascentium.com/blog/crm/Post533.aspx.
Aaron has come up with a solution to expose the Disassociate and Associate event using a SQL script. This is unsupported customization and Microsoft is not supporting these changes.
Create a flag at the master entity named IsDirty and place that attribute at a hidden tab.
At onload event simply mark this attribute as true.
crmForm.all.new_isdirty.DataValue = !crmForm.all.new_isdirty.DataValue;
Now you can have an attribute that prompts user every time to save the form and you can plan a workflow or plugin that executes on update of this event.
This is a supported customization and can easily upgraded.