Building a Sitecore personalization rule with multiple options

  1. Create a new Condition that inherits StringOperatorCondition.

    using Sitecore.Diagnostics;
    using Sitecore.Rules;
    using Sitecore.Rules.Conditions;
    using System;
    
    namespace Customer.Feature.FeatureName.Rules.Conditions
    {
      public class NewCondition<T> : StringOperatorCondition<T> where T : RuleContext
      {
        public string Value { get; set; }
    
        protected override bool Execute(T ruleContext)
        {
          Assert.ArgumentNotNull(ruleContext, "ruleContext");
    
          // Logic that determines whether the rule applies.
    
          return true;
        }
      }
    }
  2. Create a new Condition under

    /sitecore/system/Settings/Rules/Definitions/Elements
  3. Create a folder underneath the Condition to contain the option types.

  4. Create items of Standard Template to represent each option type. Leverage the name within your logic and set the display name to something helpful for the author.

  5. Set the Text of the condition to:

    where the (context) has any [Value,TreeList,root=/sitecore/system/Settings/Rules/Definitions/Elements/Options&&selection={1930BBEB-7805-471A-A3BE-4858AC7CF696}, the list]
  6. Set the Type of the condition to:

    Customer.Feature.FeatureName.Rules.Conditions.NewCondition, Customer.Feature.FeatureName