Skip to main content

Better if you update datasource of the Component(e.g. Rendering) with a new field of "Rules" type. Create a new template, have a single field with Field Type (Rules) Inherit your datasource's template with this new template.

Now have a Rule placed on your datasource item. and execute it like this way:

public static bool MyRules(this RuleList ruleList, T ruleContext) where T : RuleContext {

if (ruleList.Rules != null && ruleList.Rules.Any()) { if (ruleList.Rules.All(x => x.Condition == null)) { return true; } else { foreach (var rule in ruleList.Rules) { if (rule.Condition == null) continue; var result = rule.Evaluate(ruleContext); if (ruleContext.IsAborted) return false; if (result) return true; } } } return false; }

public static bool MyRules<T>(this RuleList<T> ruleList, T ruleContext) where T : RuleContext { if (ruleList.Rules != null && ruleList.Rules.Any()) { if (ruleList.Rules.All(x => x.Condition == null)) { return true; } else { foreach (var rule in ruleList.Rules) { if (rule.Condition == null) continue; var result = rule.Evaluate(ruleContext); if (ruleContext.IsAborted) return false; if (result) return true; } } } return false; } 

Call it like: var context = new RuleContext(); datasource.RuleFieldName.MyRule(context);

var context = new RuleContext(); datasource.RuleFieldName.MyRule(context); 

Now it should decide whether goal is achieved or not. if default rule does not work, do same with some custom Rule and i think it will work.

Better if you update datasource of the Component(e.g. Rendering) with a new field of "Rules" type. Create a new template, have a single field with Field Type (Rules) Inherit your datasource's template with this new template.

Now have a Rule placed on your datasource item. and execute it like this way:

public static bool MyRules(this RuleList ruleList, T ruleContext) where T : RuleContext {

if (ruleList.Rules != null && ruleList.Rules.Any()) { if (ruleList.Rules.All(x => x.Condition == null)) { return true; } else { foreach (var rule in ruleList.Rules) { if (rule.Condition == null) continue; var result = rule.Evaluate(ruleContext); if (ruleContext.IsAborted) return false; if (result) return true; } } } return false; }

Call it like: var context = new RuleContext(); datasource.RuleFieldName.MyRule(context);

Now it should decide whether goal is achieved or not. if default rule does not work, do same with some custom Rule and i think it will work.

Better if you update datasource of the Component(e.g. Rendering) with a new field of "Rules" type. Create a new template, have a single field with Field Type (Rules) Inherit your datasource's template with this new template.

Now have a Rule placed on your datasource item. and execute it like this way:

public static bool MyRules<T>(this RuleList<T> ruleList, T ruleContext) where T : RuleContext { if (ruleList.Rules != null && ruleList.Rules.Any()) { if (ruleList.Rules.All(x => x.Condition == null)) { return true; } else { foreach (var rule in ruleList.Rules) { if (rule.Condition == null) continue; var result = rule.Evaluate(ruleContext); if (ruleContext.IsAborted) return false; if (result) return true; } } } return false; } 

Call it like:

var context = new RuleContext(); datasource.RuleFieldName.MyRule(context); 

Now it should decide whether goal is achieved or not. if default rule does not work, do same with some custom Rule and i think it will work.

Source Link

Better if you update datasource of the Component(e.g. Rendering) with a new field of "Rules" type. Create a new template, have a single field with Field Type (Rules) Inherit your datasource's template with this new template.

Now have a Rule placed on your datasource item. and execute it like this way:

public static bool MyRules(this RuleList ruleList, T ruleContext) where T : RuleContext {

if (ruleList.Rules != null && ruleList.Rules.Any()) { if (ruleList.Rules.All(x => x.Condition == null)) { return true; } else { foreach (var rule in ruleList.Rules) { if (rule.Condition == null) continue; var result = rule.Evaluate(ruleContext); if (ruleContext.IsAborted) return false; if (result) return true; } } } return false; }

Call it like: var context = new RuleContext(); datasource.RuleFieldName.MyRule(context);

Now it should decide whether goal is achieved or not. if default rule does not work, do same with some custom Rule and i think it will work.