In this scenario you have a custom entity called Training Course which has an N:N relationship with the Contact entity. It basically records each time a contact attends a training course. You need to implement a business rule that populates a field called 'Last Training Course' each time a contact attends a training course. The screenshot below shows the Last Training Course field on the contact entity.
The screenshot below shows the training course entity and show the many to many (N:N) relationship to the contact entity.
North52 Decision Suite Solution
The North52 Decision Suite solution works like this,
- We create a formula that can hook into the Associate & Disassociate events within Dynamics 365. So it executes whenever a many to many relationship gets created or removed.
- As the association events are generic we need to check for the schema name of the N:N relationship between the 2 entities
- If the schema name matches then we execute an update on the contact record to set the 'Last Training Course' field
- The GetAssociationRelatedEntityreferenceId() function retrieves the contactid for the contact that is being added to the training course
North52 Decision Suite Steps
The following set of steps assumes you have an entity called Training Course already created with a N:N relationship between it & the contact entity
- Create a new formula of type 'N:N Associate'
- Set the Source Entity to 'Training Course'
- Copy & paste the formula below into the formula description field & click save
- You are ready to test
if(GetAssociationRelationshipName() = 'new_trainingcourse_contact', UpdateRecord('contact', GetAssociationRelatedEntityreferenceId(), SetAttributeLookup('new_last_training_courseid', 'new_trainingcourse', [new_trainingcourse.new_trainingcourseid])), 'NoOp')
Note 1: You will need to setup the exact same formula but set the Formula Type to N:N Disassociate if you need to handle contacts being removed from the many to many relationship
Did you know?
North52 Decision Suite helps organizations in all Industries
The North52 Decision Suite allows organizations to manage and automate the many decisions found in your processes. North52 helps:
- Automate costly and repetitive decisions
- Monitor and improve the quality of decisions
- Ensure consistency
- Enable fast response to change
All organizations in all industries can benefit from software that automate decisions related to risk, compliance, and configuration.