Search code examples
sitecorerule-enginesitecore8personalization

NULL property value for a custom Personalization Condition


I need to create a custom Condition for Personalization to check if a specific time has passed (without date). So I created the new class as following:

public class TimePassedCondition<T> : Sitecore.Rules.Conditions.OperatorCondition<T> where T : RuleContext
{
     public string SelectedTime { get; set; }

     protected override bool Execute(T ruleContext)
     {
        //TODO: Add Logic
        return false;
    }
}

Then I added a new Condition definition in

Sitecore/System/Settings/Rules/Elements/Date/ and i gave it the following Text: when [SelectedTime,DateTime,,the time] has passed I also added the new Personalization Condition and Action to the required component. So when I debug and open the page, the break points gets hit.

However, my problem is that according to what I read in several articles, the SelectedTime property should be filled with the datetime selected when I created the Personalization Condition, but it is always NULL for me.

What am I missing?

Note: this is Sitecore 8.1


Solution

  • Completely clear out the personalization conditions and rebuild them.

    Personalization is stored as XML in a <condition> element with attribute names that mirror your storage variable name. This is problematic if you refactor the underlying storage variable in the rule text - they don't stay in sync and won't be mapped when the rule is run.