6

I have some personalization conditions. None of these seem to execute. When debugging, none of the rules stop with break points. I have tried using the most simple built in rules such as when [date] has passed to no avail. It is just not stepping through the conditions.

This is on Sitecore.NET 8.2 (rev. 160729)

I have values Xdb.Enabled and Xdb.Tracking.Enabled set to true.

I am testing in normal mode. I have Sitecore.xDB.base license.

I see nothing in logs.

Below are the control properties and personalization rules. If the control does not have a data source nothing shows.

Control Properties

Personalization Rules

I have seen all of the custom rules execute correctly. This is the only rule that I have not seen execute correctly. Possibly if there is one rule that is incorrect it would stop personalization running altogether?

public class AptifyMemberDuesPaidThruCondition<T> : OperatorCondition<T> where T : RuleContext
{
    private readonly IAptifyAuthenticator _aptifyAuthenticator;

    public AptifyMemberDuesPaidThruCondition() : this(ServiceLocator.ServiceProvider.GetService<IAptifyAuthenticator>())
    { }

    public AptifyMemberDuesPaidThruCondition(IAptifyAuthenticator aptifyAuthenticator)
    {
        _aptifyAuthenticator = aptifyAuthenticator;
    }

    public string DuesPaidThru { get; set; }

    /// <summary>
    /// This function will be called to test the condition
    /// </summary>       
    protected override bool Execute(T ruleContext)
    {

        //Check if the user is logged in, otherwise return false
        if (!_aptifyAuthenticator.UserAptifyAuthenticated())
            return false;

        DateTime dateTime = DateUtil.ParseDateTime(this.DuesPaidThru, DateTime.MinValue);
        if (dateTime.Kind != DateTimeKind.Utc)
        {
            string str = string.Concat("AptifyMemberDuesPaidThruCondition<T> expects UTC date, but date with different kind has been assigned to Now property: ", this.DuesPaidThru);
            Log.Warn(str, this);
        }

        var actualDuesPaidThru = _aptifyAuthenticator.GetUserCustomerPropertyDate(AuthenticatedPropertyName.DuesPaidThru);

        if (!actualDuesPaidThru.HasValue)
            return false;

        return DateComparer(actualDuesPaidThru.Value, dateTime, GetOperator());

    }

    private bool DateComparer(DateTime date1, DateTime date2, ConditionOperator conditionOperator)
    {

        switch (conditionOperator)
        {
            case ConditionOperator.Equal:
                return date1.Equals(date2);
            case ConditionOperator.LessThan:
                return date1 < date2;
            case ConditionOperator.LessThanOrEqual:
                return date1 <= date2;
            case ConditionOperator.GreaterThan:
                return date1 > date2;
            case ConditionOperator.GreaterThanOrEqual:
                return date1 >= date2;
            case ConditionOperator.NotEqual:
                return !date1.Equals(date2);
            default:
                return false;
        }

    }
}

Any ideas where to troubleshoot?

Update: this started working after I went to web database, modified a property (not related to personalization) and saved the item. This indicates some other kind of issue.

Update 2: it stopped working with no changes. I can change the item and see changes, but personalization is now not working. It is like it just turns off.

  • Do you test in normal mode? Rules are not executed in edit or preview – Marek Musielak Oct 11 '18 at 17:24
  • I am testing in normal mode. – Jonathan Folland Oct 11 '18 at 17:31
  • Can you add some screenshots of your rule configurations and some code snippets of your config and/or any custom rule actions you've defined? – Dan Sinclair Oct 15 '18 at 13:02
  • Added screenshots. Shows built-in rule not working. – Jonathan Folland Oct 15 '18 at 15:12
  • Is the component which holds the rules cached? – Hishaam Namooya Oct 15 '18 at 19:32
0

The sitecore default rules are supposed to be executed without additional steps. You can check the following to troubleshoot further. 1. Is the personalization rendering added to shared renderings section or final rendering section? 2. Did you publish the page and if so check the web database to see if the personalization rendering is present in web database.

  • Personalization rendering is in final rendering section. Personalization is in web database. – Jonathan Folland Oct 15 '18 at 13:51
0

Sitecore default Rules execute without any custom code but if you want to write your own Rules then you can use below:

public class AptifyMemberDuesPaidThruCondition : WhenCondition where T : RuleContext

However there can be many reasons for this issue. Refer:

Is it possible to use any personalisation rules without xDB

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.