﻿#### 

Sitecore 9.1 was released with a number of new Marketing Automation [features and enhancements](https://dev.sitecore.net/Downloads/Sitecore%20Experience%20Platform/91/Sitecore%20Experience%20Platform%2091%20Initial%20Release/Release%20Notes "Sitecore experience release 9.1"). Some of the highly anticipated features are: 

- Enrollment controls that define how many times a contact can be enrolled in a campaign
- Campaign templates and a number of predefined templates for contact Acquisition, Conversion, Win Back and Account Development
- Ability to enroll contacts from a list and remove individual contacts from automation plan

Out of the box, Sitecore 9.0 does not allow to enroll a contact to the same automation plan multiple times. Generally speaking a plan like Abandoned Cart (where a customer fails to complete an order, an automated marketing email will be sent to the recipient) would only be triggered once for each contact. 

This post is aimed to clarify how Sitecore 9.1 addresses the ability to enroll a contact multiple times. 

Sitecore 9.1 comes with a new Maximum Enrollments property available in Marketing Automation UI

![Marketing Automation UI](https://www.brimit.com/-/media/images/blog/smaenrollmentsnumber1.png?la=en&amp;hash=5E6C72A0948D82CB12B98911830B7C52)

It is possible to specify an exact number of enrollments (10 in the above sample plan) or set it to Unlimited. Looks simple but in fact, there are more details to consider.

Let’s have a close look at automation plan definition in Sitecore 9.1 and 9.0.  

![marketing automation plan definition](https://www.brimit.com/-/media/images/blog/smaenrollmentsnumber2.png?la=en&amp;hash=9ADC3E8596D3562B2D1BE75A10DA7704)

Notice new properties added comparing to Sitecore 9.0 are **NewEnrollmentRegulatorType** and its param **MaxEnrollmentCount**. Changes in Marketing Automation UI will be saved with it. When you create new MA plan default value for NewEnrollmentRegulatorType is null, meaning an Unlimited number of enrollments. There are two more extremely important properties: **ReentryMode** (default: 0) and **ContextKeyFactory** (default: Null) both available since Sitecore 9.0

If you give it a try and save a plan with Unlimited number of enrollments (or NewEnrollmentRegulatorType and MaxEnrollmentCount in place) it wont work. Any contact will be enrolled to such plan only once. Unfortunately there is a bug in Sitecore 9.1 (ID: 297306 if you need to request hotfix) which sets **ReentryMode** to **0** by default. 

**ReentryMode** set to 0 (None), will prevent Sitecore from taking NewEnrollmentRegulatorType into account.

With ReentryMode set to 0, Marketing Automation engine EventProcessor will not allow plan entry if &lt;**AutomationPlanExit**&gt; contact facet has such plan listed at least once, i.e. if a contact has already been processed by a plan, it will not be enrolled again to the same plan. If a contact is already in the plan, a second enrollment will not be allowed.

**ReentryMode** set to 1 (Single) solves the problem.

You can change the default value for ReentryMode and set it to 1 (Single). In this mode Sitecore will allow multiple enrollments and will respect the implementation of **NewEnrollmentRegulatorType** and **MaxEnrollmentCount** param. With hotfix **ReentryMode** will be set to Single by default. Default NewEnrollmentRegulatorType implementation compares the number of plan exits for a contact (as defined by &lt;AutomationPlanExit&gt; contact facet) against MaxEnrollmentCount value set in definition.

It is slightly confusing that **Single** ReentryMode and **MaxEnrollmentCount** come together, but it makes perfect sense. Single mode is aimed to enable one-to-many enrollments for a given contact but a Single enrollment at the same time. I.e. contact has to exit a plan before it can enter it again.

The last but not least value available for **ReentryMode** is 2, meaning **Multiple**. 

With Multiple mode you can make contact enrolled multiple times at the same time. I.e. contact does not have to exit a plan before it can enter it again. In order to enable such mode, you will have to implement **ContextKeyFactoryType** and manually set it in the definition. This option is available since Sitecore 9.0 initial release. ContextKeyFactorType will need to provide a unique **contextKey** that will help Sitecore understand how to treat **multiple simultaneous** enrollments for individual contact. 

A good example would be **Review Your Purchase** automation, where a contact is invited by email to review order items in 2 weeks since an order is placed and obviously another order can be placed at the same time that we also want a review made. In this automation example OrderID is a perfect value for contextKey. Another post with **ContextKeyFactoryType** sample implementation will come later.

All above applies to interactions(events) based enrollment triggered by xConnect and Live Events processing.

What about manual enrollments from UI or enrollment with Marketing Automation Operations API?

The behavior is slightly different when a contact is enrolled from MA UI or MA Operations API. With default ReentryMode set to None (remember it is a bug), contact will be enrolled multiple times assuming its not in a plan already. I.e. it will behave much like a Single re-entry mode. 

Another important difference is that in Single mode **it will ignore the NewEnrollmentRegulatorType and MaxEnrollmentCount** properties. So you can manually enroll a contact as many times as you need in both None and Single mode. 

The behaviour for **Multiple** ReentryMode mode is similar. If a contact is already enrolled the following error is recorded in logs upon another enrollment from UI:

```
  2018-12-07 12:53:41.294 +03:00 [Error] Failed to create activity enrollment  "ActivityEnrollmentKey: { ContactId: ...…..: "EnrollmentAlreadyExists" (EnrollmentAlreadyExists). Error message: null
```

MA engine will be retrying to add contact 100 times. A default **AttempLimit** value set for &lt;MarketingAutomation.AttemptLimitWorkItemRegulator&gt; which you can adjust it in **sc.MarketingAutomation.PoolFilter.xml** config

So you will still need to implement ContextKeyFactory to enroll the same contact by MA UI or Operations API multiple times simultaneously.

[Sitecore documentation](https://doc.sitecore.com/developers/91/sitecore-experience-platform/en/plan-and-activity-enrollment.html "Sitecore automation documentation") provides a great starting point to understand a number of scenarios when contact is enrolled in Automation plan. 

Fly high with Sitecore 9.1!

#### Read more on marketing automation and Sitecore 9:

- [Creating Activity Type backend logic and definition item](https://www.brimit.com/blog/sitecore-marketing-automation-creating-activity-definition "Sitecore Activity Type")
- [Deploying Activity Type to Sitecore UI and Marketing Automation engine](https://www.brimit.com/blog/sitecore-marketing-automation-deploying-activity-type-automation-engine "Marketing Automation engine")
- [Creating Activity Type UI and Editor](https://www.brimit.com/blog/sitecore-marketing-automation-creating-activity-editor "Creating Activity Type")
- [Custom Marketing Automation Action - Introduction](https://www.brimit.com/blog/sitecore-9-custom-marketing-automation-action "Custom Marketing Automation Action")
- [Marketing Automation API - enrolling contacts](https://www.brimit.com/blog/sitecore-marketing-automation-api-enrolling-contacts "Marketing Automation API")

##### Do you need help with your Sitecore project?

      ![](~/media/CD37043DFD1F491D8E92958A11959F75.ashx?la=en&amp;hash=D08B252DD3B41C09B588007541E5D22F)

   [VIEW SITECORE SERVICES](https://www.brimit.com/expertise/sitecore-cms)

###### Author

[!\[Alexei Vershalovich\](https://www.brimit.com/-/jssmedia/feature/blogs/authors/alexei-vershalovich-brimit---500.png?h=1098&amp;iar=0&amp;w=1042&amp;hash=7551A887E43E4DDE95E9C95102DBDF1B)
Alexei Vershalovich
Principal Consultant, digital experience and e-commerce](https://www.brimit.com/blog/author?authors=Alexei%20Vershalovich)

#### More on Sitecore

[!\[How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2024/vercel_cover-image.png)
#Guides#How-toDXPE-commerce
##### How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects
Optimize and accelerate the development and deployment of complex multisite Sitecore projects.
Alexei Vershalovich on July 17, 2024](https://www.brimit.com/blog/how-vercel-will-help-you-save-effort-when-deploying-sophisticated-sitecore-projects)

[!\[Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2023/sitecore-mentoring---cover-image.png)
#How-toDXP
##### Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story
How to participate in the Sitecore Mentor program and help younger colleagues jump-start a career in Sitecore development.
Sergey Baranov on October 2, 2023](https://www.brimit.com/blog/training-up-tomorrows-sitecore-mvps)

[!\[Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2022/headless/adobestock_456986731.jpg)
#How-toDXPE-commerce
##### Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)
Discover how a headless CMS can benefit organizations that use Sitecore.
Daniil Raschupkin, Palina Trokhautsava on September 15, 2022](https://www.brimit.com/blog/going-headless-part-2-when-a-headless-cms-is-your-best-bet-if-you-have-sitecore)

![](https://bat.bing.net/action/0?ti=187017043&amp;tm=gtm002&amp;Ver=2&amp;mid=1d91da8c-859e-4984-8e8e-61eedc6cc277&amp;bo=2&amp;gtm_tag_source=1&amp;pi=0&amp;lg=en-US&amp;sw=800&amp;sh=600&amp;sc=24&amp;nwd=1&amp;tl=Sitecore%209.1%20Marketing%20Automation%20-%20Repeated%20and%20concurrent%20contact%20enrollments&amp;kw=Sitecore,%209,%20Custom,%20Marketing,%20%20Automation,%20multiple%20enrollments,%20Campaign%20templates%20&amp;p=https%3A%2F%2Fwww.brimit.com%2Fblog%2Fsitecore-9-marketing-automation-multiple-enrollments&amp;r=&amp;lt=285&amp;evt=pageLoad&amp;sv=2&amp;asc=D&amp;cdb=AQAY&amp;rn=912829)