Limiting Conditions and Actions with Sitecore 7.1

Sitecore 7.1 was released today and I suspect most of the attention will be focused on SPEAK. But there are other new features included in the release, including a change to the Rule Set Editor. And one of the changes is a greatly improved ability to control which conditions and actions appear when configuring rules.

If you're already using the rule editor in Sitecore you will want to read this post to learn about those changes. And if you're not, this post can serve as an introduction to a powerful configuration tool you may want to consider adding to your Sitecore toolkit.

Common Conditions and Actions

In previous versions of Sitecore, there was a set of "common" conditions and actions that always would appear when you would use the rules field. If you add a Rules field to a template and then edit the field, this is what you would see:

In Sitecore 7.1 this is no longer the case. If you simply add a rules field to a template and then edit the field, you see no conditions or actions. This means you have better control over which conditions and actions appear.

Controlling Which Actions and Conditions Appear

In previous versions of Sitecore the Rules field allowed you to specify a source. The source would be a folder that contained conditions and actions, and those conditions and actions would be added to the "common" conditions and actions. The result was that you could reuse conditions and actions, but without much precision.

In Sitecore 7.1 conditions and renderings are defined under /sitecore/system/Settings/Rules/Definitions/Elements. They are still grouped, but now they are grouped under an item based on the template /sitecore/templates/System/Rules/Taxonomy/Element Folder.

Under an Element Folder you can define conditions and actions. You also specify tags which are used later to select the conditions and actions. The following shows the conditions defined for dates, along with the tags that are assigned.

Now, how do you tell the Rule Set Editor to display these conditions? This is where another new template is used. Items based on the template /sitecore/templates/System/Rules/Taxonomy/Rules Context Folder are defined under /sitecore/system/Settings/Rules. Under a Rules Context Folder item is an item Tags. The children of the Tags item are Tags Definition items. When you assign a tag to a Tags Definition item, all of the conditions and actions whose tags match are displayed in a Rules field that uses the Rules Context Folder item as its source.

OK, that was a pretty dense paragraph.  Here are some screenshots for those of you who are visual learners:

First I define a new tag for my conditions, which will be ecommerce-related:

Then I define some new conditions that relate to ecommerce:

Next I assign the ecommerce tag to the conditions:

Now I create the Rules Context Folder which will eventually serve as the source for the Rules field in my template. I assign the Ecommerce tag to indicate I want to include conditions and actions with that tag:

Now I can assign a source to the Rules field in my template:

Disabling Actions

Actions can be disabled the same way they were in previous versions of Sitecore. The following value would be used for the Source value for the Rules field in order to display the ecommerce conditions without the actions: