By default Sitecore provides a number of rules which are triggered by existing Sitecore pipelines. However, the number of pipelines that will execute rules by default is limited compared to the number of available pipelines. Some examples of existing rules that are executed by pipelines are Item Deleted, Item Saved, and Version Removed. Adding a new rule set that is executed by a pipeline can be accomplished by implementing an event handler.

Executing a Custom Rule Set with the ItemAdded Event

Our handler extracts the item from the EventArgs object, then we define what rule set to execute. In this case, we only want to execute the rules contained in our newly created Item Added rules context folder. Next we create an instance of RuleContext, alternatively we can also implement our own custom RuleContext class by inheriting from the RuleContext class. Now whenever the ItemAdded event is fired the Rules Engine will execute our Item Added rules.

This is the item the rulesFolderID var is referencing

This code shouldn't be used without adding validation.