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