Issue with using Engagement Automation conditions in personalization


Description

Sitecore enables you to create personalization rules based on different types of conditions, including Engagement Automation. For example, it is possible to verify if a visitor is added to a specific engagement plan by using a rule such as:

However, from Sitecore 7.5 the Engagement Automation conditions are not designed for the Conditional Rendering context. Therefore, these rules are no longer available by default in the Rule Set Editor for Personalization.

Note: Adding "Enagagement Automation" to the Tags field of the /sitecore/system/Settings/Rules/Conditional Renderings/Tags/Default item will make the rules appear in the Rule Set Editor dialog. However, using these conditions will cause the following error in logs:

ERROR Failed to get type of condition
Exception: System.ArgumentException
Message: GenericArguments[0], 'Sitecore.Rules.ConditionalRenderings.ConditionalRenderingsRuleContext', on 'Sitecore.Analytics.Automation.Rules.Workflows.Conditions.HasAutomationStateCondition`1[T]' violates the constraint of type 'T'.
Source: mscorlib
   at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
   at System.RuntimeType.MakeGenericType(Type[] instantiation)
   at Sitecore.Reflection.ReflectionUtil.GetGenericType(String typeName, Type genericArgumentType)
   at Sitecore.CodeDom.Scripts.ItemScripts.GetGenericType[T](Item item)
   at Sitecore.Rules.RuleFactory.GetRuleCondition[T](Database database, XElement element)
...

Solution

To fix the described issue, apply the following patch:

  1. Put the attached Sitecore.Support.424148.dll assembly in your \Website\bin folder.
  2. In the Type field of the /sitecore/system/Settings/Rules/Definitions/Elements/Engagement Automation/Is in Engagement Plan item ({131CC7E1-6DA4-4875-897F-79E0198EC26F}), enter the following value:
    Sitecore.Support.Analytics.Automation.Rules.Workflows.Conditions.HasAutomationCondition,Sitecore.Support.424148
  3. In the Type field of the /sitecore/system/Settings/Rules/Definitions/Elements/Engagement Automation/Is in Specific State item ({78168526-2783-4700-AD73-E78B9A056027}), enter the following value: 
    Sitecore.Support.Analytics.Automation.Rules.Workflows.Conditions.HasAutomationStateCondition,
    Sitecore.Support.424148
  4. Republish the items modified above.