Controlling Dynamics Offspring

Dynamics_200If you have a requirement to limit the number of child records possible in a 1:N relationship, the Dynamics Rollup field is a handy way to achieve the restriction.

This solution has three parts:

  1. Two entities with 1:N relationship to each other.
  2. Rollup whole number field on parent entity configured to use the COUNT function which counts the child records.
  3. On create workflow on child entity with a condition to evaluate the value of the rollup field and stop record creation if it exceeds the allowed record count.

Rollup

To Implement

(1) Create the rollup field on the parent entity.

Data Type = whole number

Field Type = rollup

Rollup_FieldConfig

 

 

 

 

 

 

 

 

 

 

Click the Edit button to configure the rollup.

You can also add a filter to limit the function to only count child records which meet a specific criteria; like, have a certain eye color.

(2) Create a workflow on the child entity. Configure it to run “on create” and as the very first step evaluate the value of the rollup field.  If it exceeds the number of records allowed, “Stop” the workflow as CANCELLED and configure an error message to display to the user.

note TIP: Add a step to call a forced calculation of the rollup at the end of the workflow.  This ensures it has the correct value at all times.  A plug-in to force a calculation can be found in Dynamics 365 Workflow Tools.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.