1

I'm trying to create an XConnect custom contact purge condition for any contacts with 0 interactions. I've followed this walkthrough but I must be missing something as it's not registered when trying to run it via the CLI. This is the walkthrough I'm using.

Implemented an ICondition interface

using Sitecore.XConnect;
using Sitecore.XConnect.DataTools.Abstractions.Conditions;

namespace PlanetExpress.Foundation.Models.Conditions
{
    public class ContactNoInteractionsCondition : ICondition
    {
        public string ConditionId { get; } = "ContactNoInteractionsCondition";
        public bool IsAccepted(Contact contact)
        {            
            return contact.Interactions.Count == 0;
        }
    }
}

The reason why it's PlanetExpress.Foundation.Models is because it'll be copied across to XConnect with the way we deploy our containers along with other custom facets. I've checked the XConnect container and can see the DLL is there.

Register the custom condition

Created the config - as it will process the patch after the config under Processing

App_Data/Config/Sitecore/Processing_patch/sc.XConnect.DataTools.Conditions.xml

    <?xml version="1.0" encoding="utf-8" ?>
    <Settings>
      <Sitecore>
        <Processing>
          <Services>
            <Condition.AnonymousCondition>
              <Type>Sitecore.XConnect.DataTools.Conditions.AnonymousCondition, Sitecore.XConnect.DataTools.Conditions</Type>
              <As>Sitecore.XConnect.DataTools.Abstractions.Conditions.ICondition, Sitecore.XConnect.DataTools.Abstractions</As>
              <LifeTime>Singleton</LifeTime>
            </Condition.AnonymousCondition>      
            <Condition.ContactNoInteractionsCondition>
              <Type>PlanetExpress.Foundation.Models.Conditions.ContactNoInteractionsCondition,PlanetExpress.Foundation.Models</Type>
              <As>Sitecore.XConnect.DataTools.Abstractions.Conditions.ICondition, Sitecore.XConnect.DataTools.Abstractions</As>
              <LifeTime>Singleton</LifeTime>
            </Condition.ContactNoInteractionsCondition>
          </Services>
        </Processing>
      </Sitecore>
    </Settings>

There is another config file in the same folder, and that config does apply (to adjust cutoffdays). I can see the conditions config file sitting on the container as well, so it exists.

I'm not sure if the code will do the job, trying to test it, however, the issue I'm having is that ContactNoInteractionsCondition doesn't get picked up by XConnect\CLI when running the following command

$ dotnet sitecore xconnect purge contacts start --cds "ContactNoInteractionsCondition" --cutoffdays 91 -t -v
Registering delete contacts task: cutoffDays = 91;conditions = ContactNoInteractionsCondition;batchSize = 100;
Cannot register delete contacts task. The following conditions are not found: ContactNoInteractionsCondition
An error has occurred, and the task is not registered.

Sitecore instance is 10.2

CLI is running [email protected] version of the plugin

2 Answers 2

1

Having recently implemented something similar (I wrote about it here), I think you may be missing a config that essentially whitelists the conditions that can be used on the cortex processing role. NB: The service will depend on your topology. It is the service that accepts the tasks (eg. xconnect in xp0, cortexprocessing in xp1).

You'll need to add a patch similar to this:

<?xml version="1.0" encoding="utf-8" ?>
<Settings>
    <Sitecore>
        <Processing>
            <Services>
                <DataPurgeTaskOptionsValidatorOptions>
                    <Options>
                        <AllowedContactConditionIds>
                            <AintNoInteractions>ContactNoInteractionsCondition</AintNoInteractions>
                        </AllowedContactConditionIds>
                    </Options>
                </DataPurgeTaskOptionsValidatorOptions>
            </Services>
        </Processing>
    </Sitecore>
</Settings>

Not sure why, but it's not mentioned in the walkthrough, but will result in the behavour you're seeing if it's not there. For reference, the base config can be found in App_Data/Config/Sitecore/Processing/sc.XConnect.DataPurge.Validation.xml .

Bonus: Unfortunately some bad news, as I think what you're trying to achieve won't work without some additional work as the Contact object passing through in IsAccepted won't have any Interactions in the property. You could verify this with some debugging/additional logging to test. You would need to find a way to query this data via usual methods (e.g. xconnect or search client). This is explicity called out in a note in the documentation:

The conditions are limited to filter by contact data and contact identifiers. You cannot create a condition based on the contact facet or interaction data in Sitecore 10.1.

NB: that's from the 10.2 walkthrough doco you referred to.

1
  • This was the missing piece, thank you! the CLI is now picking up the custom condition.
    – spyn
    Nov 15 at 2:27
1

When registering a purge task (direct request through the Web API or the DevEx CLI plugin), the purging tool checks the CutoffDays or StartedDaysCutoff parameter against the specified MinimumContactCutoffDays or MinimumInteractionStartedDaysCutoff values accordingly (The minimum available value is 180 days by default.). This prevents registering a task that deletes all the data from the collection database.

To configure the minimum number of days:

  • Open the configuration file <Processing Engine>\App_Data\Config\Sitecore\Processing\sc.XConnect.DataPurge.Validation.xml and modify the MinimumContactCutoffDays or the MinimumInteractionStartedDaysCutoff value.

When the configuration setting changes, you must manually restart the Cortex Processing Engine.

Hope it helps!

1
  • MinimumContactCutoffDays and MinimumInteractionStartedDaysCutoff is set to 90, so that part of the config is all good. XConnect is having problems identifying the condition.
    – spyn
    Aug 2 at 5:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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