I have created a new Rule action on which to create a bucketing structure which takes in a selected date field and build the structure off of that date field. However, this rule is never hit. I have tried debugging, but the code is never hit and I am not sure why.
I have created a rule in the Item Bucket Settings in the format of:
where the item bucket is based on the Bucket template
and where the new bucketable item is based on the bucketable template
create the folder structure based on the field Selected Date of the new bucketable item
and
created a rule action under settings/Rules/Definitions/Bucketing with the following:
(The Image is a screenshot of the rule action)```
https://i.sstatic.net/xE288.png
This is my rule action code:
public class CreateSelectedDatePath<T> : RuleAction<T> where T : BucketingRuleContext
{
public string Field { get; set; }
public override void Apply(T ruleContext)
{
var date = ruleContext.CreationDate;
DateField dateField = ruleContext.Item.Fields[Field];
Assert.ArgumentNotNull(ruleContext, "ruleContext");
if (dateField != null)
{
date = dateField.DateTime;
}
ruleContext.ResolvedPath = date.ToString("MM.dd.yyyy", Context.Culture);
}
}```
Am I missing something?
Update! I Have found the answer.
I am using sxa, and there is a setting called BucketConfiguration.DyamicBucketFolderPath. Sxa has a SiteBucketProvider that prevents the rules under system/settings/Buckets/Item Bucket Settings to Run, because it looks for the rule on the site settings level. In order to have the custom rule fire, it needs to be added to the site settings.