<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Sitecore Xperiences &#187; Rules</title>
	<atom:link href="https://blog.peplau.com.br/category/rules/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.peplau.com.br</link>
	<description>The things I&#039;ve seen as a Sitecore Professional</description>
	<lastBuildDate>Sun, 09 Mar 2025 21:54:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.41</generator>
	<item>
		<title>Custom rule condition to find Top-N Profile Key</title>
		<link>https://blog.peplau.com.br/custom-rule-condition-to-find-top-n-profile-key/</link>
		<comments>https://blog.peplau.com.br/custom-rule-condition-to-find-top-n-profile-key/#comments</comments>
		<pubDate>Mon, 09 Sep 2019 17:19:01 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Rules]]></category>
		<category><![CDATA[xDB]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=792</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/custom-rule-condition-to-find-top-n-profile-key/"></div>Here we are for another simple yet useful tip from the Smart Bookshelf Demo. Although we are now improving it with some Artificial Intelligence, the first version has Sitecore Rules-based Personalization in the hearth of the recommendation mechanism. Our desired behavior is to light-up LED strips from the top 3 Book Genres, such as seen below: The books you see on [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Here we are for another simple yet useful tip from the Smart Bookshelf Demo. Although we are now improving it with some Artificial Intelligence, the first version has Sitecore Rules-based Personalization in the hearth of the recommendation mechanism.</p>
<p>Our desired behavior is to light-up LED strips from the top 3 Book Genres, such as seen below:</p>
<p><img class="alignnone wp-image-795 size-large" src="http://blog.peplau.com.br/wp-content/uploads/Face-Detection-picture-1024x539.jpg" alt="Face Detection picture" width="605" height="318" /></p>
<p>The books you see on screen are shown according to the top 3 genres for the current visitor.</p>
<p>It automatically scrolls, showing one genre each time. Here is how the component looks like:</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/Recommended-Books.jpg"><img class="alignnone wp-image-793 size-full" src="http://blog.peplau.com.br/wp-content/uploads/Recommended-Books.jpg" alt="Recommended Books" width="670" height="709" /></a></p>
<p>Our content tree is composed by Genre Pages, each of them with respective Profile Card assigned:</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/Mapping-Genres-and-Profile-Cards.jpg"><img class="alignnone wp-image-797" src="http://blog.peplau.com.br/wp-content/uploads/Mapping-Genres-and-Profile-Cards-1024x412.jpg" alt="Mapping Genres and Profile Cards" width="1025" height="412" /></a></p>
<p>So when your visitor visits a Genre Page, he or she will get points for that respective Profile Card, enabling Sitecore to register and track what are the preferred genres. The same thing also happens when a Book Page is visited (achieved by <a href="http://blog.peplau.com.br/en_US/programmatically-visit-a-page-and-all-xdb-related/" target="_blank">using the technique explained in my last post</a>).</p>
<p>At this point we are already able to see preferred genres for our contacts, by opening any known contact at the Experience Profile:</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/Experience-Profile-shows-preferred-Genres.jpg"><img class="alignnone size-medium wp-image-798" src="http://blog.peplau.com.br/wp-content/uploads/Experience-Profile-shows-preferred-Genres-273x300.jpg" alt="Experience Profile shows preferred Genres" width="273" height="300" /></a></p>
<p>&nbsp;</p>
<h2>Rules Conditions</h2>
<p>We will retrieve the top 3 genres by using Rules-based Personalization. What you see below is the personalization setting required to display the Poetry Genre if it&#8217;s &#8220;top 2&#8243; for the current Visitor.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/Custom-Rule-Condition.jpg"><img class="alignnone wp-image-799 size-full" src="http://blog.peplau.com.br/wp-content/uploads/Custom-Rule-Condition.jpg" alt="Custom Rule Condition" width="549" height="143" /></a></p>
<p>&nbsp;</p>
<h2>Custom Rule Condition: Matches Pattern Best X</h2>
<p>Our custom condition is based on this OOTB condition:</p>
<pre>/sitecore/system/Settings/Rules/Definitions/Elements/Visitor/Matches Pattern</pre>
<p>However, it can only match match top 1, while our new condition accepts a number to test against.</p>
<p>&nbsp;</p>
<h3>Definition Item</h3>
<ul>
<li><strong>Path:</strong> <em>/sitecore/system/Settings/Rules/Definitions/Elements/Visitor/Matches Pattern Best X</em></li>
<li><strong>Template:</strong>  <em>/sitecore/templates/System/Rules/Condition</em></li>
<li><strong>Text:</strong> where the current contact matches best [value,Text,,specific value] on profile key [ProfileKey,ProfileKey,,profile key]</li>
<li><strong>Type:</strong> Your.Namespace.Rules.Conditions.ContactPatternMatchBestCondition, Your.AssemblyName
<ul>
<li><em>Make sure this points to your correct namespace</em></li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<h3>Source Code</h3>
<p>Here is the source code to implement this condition. After setting up the Definition Item, as described at the previous topic, all you need to use it is to compile it.</p>
<pre>using Sitecore.Abstractions;
using Sitecore.Analytics;
using Sitecore.Analytics.Tracking;
using Sitecore.Data;
using Sitecore.Framework.Conditions;
using Sitecore.Rules;
using Sitecore.Rules.Conditions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Sitecore.Diagnostics;

namespace Your.Namespace.Rules.Conditions.ContactPatternMatchBestCondition
{
   public class ContactPatternMatchBestCondition&lt;T&gt; : WhenCondition&lt;T&gt; where T : RuleContext
   {
      // ID for the item /sitecore/system/Settings/Content Testing/Personalization Suggestions/No pattern match
      private readonly ID _noPatternMatchItemId = ID.Parse("9E05C456-5CD0-405B-9D45-31DDD92AB8E4");
      private string _profileKey;
      public ContactPatternMatchBestCondition() : this(DependencyResolver.Current.GetService&lt;BaseLog&gt;()) { }

      internal ContactPatternMatchBestCondition(BaseLog log) {
         Condition.Requires&lt;BaseLog&gt;(log, nameof(log)).IsNotNull&lt;BaseLog&gt;();
         this.Log = log;
      }

      private string _value;
      public string Value {
         get =&gt; _value ?? string.Empty;
         set {
            Assert.ArgumentNotNull(value, nameof(value));
            _value = value;
         }
      }

      public string ProfileKey {
         get =&gt; _profileKey;
         set =&gt; _profileKey = value ?? string.Empty;
      }

      internal BaseLog Log { get; }

      protected override bool Execute(T ruleContext) {
         Condition.Requires&lt;T&gt;(ruleContext, nameof(ruleContext)).IsNotNull&lt;T&gt;();
         Condition.Ensures&lt;ITracker&gt;(Tracker.Current, string.Format("{0}.{1}", (object)"Tracker", 
            (object)"Current")).IsNotNull&lt;ITracker&gt;();
         Condition.Ensures&lt;Session&gt;(Tracker.Current.Session, string.Format("{0}.{1}.{2}", (object)"Tracker", 
            (object)"Current", (object)"Session")).IsNotNull&lt;Session&gt;();
         Condition.Ensures&lt;Contact&gt;(Tracker.Current.Session.Contact, string.Format("{0}.{1}.{2}.{3}", 
            (object)"Tracker", (object)"Current", (object)"Session", (object)"Contact")).IsNotNull&lt;Contact&gt;();
         if (string.IsNullOrEmpty(this.ProfileKey))
            return false;
         IEnumerable&lt;IBehaviorProfileContext&gt; profiles = Tracker.Current.Session.Contact.BehaviorProfiles.Profiles;
         List&lt;ID&gt; idsList = this.GetIdsList(this.ProfileKey);
         if (!profiles.Any&lt;IBehaviorProfileContext&gt;() &amp;&amp; idsList.Contains(this._noPatternMatchItemId))
            return true;
         if (!idsList.Any())
            return false;

         var profileKeyId = idsList.First();

         int best;
         if (!int.TryParse(Value, out best))
            return false;

         foreach (IBehaviorProfileContext profile in profiles) {
            var profileScores = GetProfileKeyValue(profile);
            if (profileScores.Count &lt; best)
               return false;

            var index = best - 1;
            var specifiedBest = profileScores[index].Key;
            var specifiedValue = profileScores[index].Value;
            var isBest = specifiedBest == profileKeyId &amp;&amp; specifiedValue&gt;0;
            if (isBest)
               return true;
         }
         return false;
      }

      private List&lt;KeyValuePair&lt;ID,double&gt;&gt; GetProfileKeyValue(IBehaviorProfileContext profile) {
         if (profile == null)
            return new List&lt;KeyValuePair&lt;ID,double&gt;&gt;();

         // ISSUE: explicit non-virtual call
         var ret = profile.Scores.ToList();
         ret.Sort((pair1,pair2) =&gt; pair2.Value.CompareTo(pair1.Value));
         return ret;
      }

      private List&lt;ID&gt; GetIdsList(string idList) {
         string[] strArray = idList.Split(new char[1] { '|' }, StringSplitOptions.RemoveEmptyEntries);
         var idList1 = new List&lt;ID&gt;();
         foreach (string str in strArray) {
            if (!string.IsNullOrEmpty(str)) {
               ID id = ID.Parse(str, ID.Null);
               if (!ID.IsNullOrEmpty(id))
                  idList1.Add(id);
            }
         }
         return idList1;
      }
   }
}</pre>
<p>Hope you enjoy it!</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/custom-rule-condition-to-find-top-n-profile-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mass data processing with Rules and Actions - The Sitecore Rule Processor Module</title>
		<link>https://blog.peplau.com.br/mass-data-processing-with-rules-and-actions-the-sitecore-rule-processor-module/</link>
		<comments>https://blog.peplau.com.br/mass-data-processing-with-rules-and-actions-the-sitecore-rule-processor-module/#comments</comments>
		<pubDate>Fri, 13 Nov 2015 16:48:14 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Actions]]></category>
		<category><![CDATA[Rules]]></category>
		<category><![CDATA[Sitecore Rule Processor]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=261</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/mass-data-processing-with-rules-and-actions-the-sitecore-rule-processor-module/"></div>One of the most laborious things in any CMS, not different in Sitecore, is the mass processing and transformation of data. It&#8217;s specially remarkable when you spend a day or two doing manual selection and edition of individual items for any reason. First time I felt that it was so painful, I ended up obsessed for a tool that could minimally automatize these kind of jobs. A bit of [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>One of the most laborious things in any CMS, not different in Sitecore, is the mass processing and transformation of data. It&#8217;s specially remarkable when you spend a day or two doing manual selection and edition of individual items for any reason. First time I felt that it was so painful, I ended up obsessed for a tool that could minimally automatize these kind of jobs.</p>
<h2>A bit of History</h2>
<p>Surprisingly I couldn&#8217;t find anything, then the only options would be sit and wait for something to arise, or create my own tool. As a born eager, I could not stay still and wait to, sooner or later, be parachuted to my next nightmare. Can&#8217;t sleep with that!</p>
<p><strong>ETL?</strong></p>
<p>When I started looking for options, based on some of my experiences with other systems, my first thought was to build or extend an ETL tool. ETL, which stands for &#8220;extract, transform and load&#8221;, is commonly used in data warehouse systems to massively retrieve, filter and modify data across different sources (SQL servers, XML files, Excel spreadsheets, web services, etc).</p>
<p>With so many good tools at the market, building an ETL tool from scratch would not be smart from my part. My best choose would be to pick an existent tool and make it able to read and write on Sitecore databases. The <strong>ItemWebAPI</strong> would make it possible, but still very low-level. That would also require some significant effort to create the configurations, business logic and interfaces to make it connect and speak with Sitecore.</p>
<p>It stood reverberating on my mind&#8230;</p>
<p><strong>Sitecore Rocks?</strong></p>
<p>I also considered creating an extension to Sitecore Rocks. That sounded like a good idea, as Sitecore Rocks already handles a considerable portion of what is needed to connect and interact with Sitecore databases. It also counts with XPath and query builders, whose logic could be used by my module to retrieve data from Sitecore. But in the other hand it would require Visual Studio to run, which would limit the module coverage, and still some UI and low-level implementation would be required.</p>
<p>And I let it reverberating on my mind&#8230;</p>
<p><strong>A Sitecore Module?</strong></p>
<p>Speaking in abrangence, my tool would preferable be a Sitecore Module instead of anything else. This way I would save time connecting to Sitecore, as the code would be executed inside of it. I would also save energy translating data back and forth as it reads and writes data on Sitecore, since I could simply use the Sitecore API as usual. That would also make things easier as the whole environment is familiar to me, and I wouldn&#8217;t have to dig down to technologies I&#8217;m not familiar with. I was trying to be pragmatic on my purpose of shielding from another nightmare with a minimum effort. Extending an existent Sitecore feature would be the best option.</p>
<p><strong>Sitecore Buckets?</strong></p>
<p>My first real attempt was to extend the <strong>Sitecore Buckets</strong> feature (image below). It has a nice UI for filtering and listing items, as well as some Search Operations that we can use to modify the items selected.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/Buckets1.png"><img class="  wp-image-265 alignnone" src="http://blog.peplau.com.br/wp-content/uploads/Buckets1.png" alt="Sitecore Buckets" width="696" height="426" /></a></p>
<p>The native Buckets system would still have to be modified in order to be used for what I wanted, but it looked like the best option till that time. Some investigation demonstrated that the change wouldn&#8217;t be trivial, more studying and investigation would be needed. I was also not very satisfied with the way that items are filtered, conditions are programmed, and how user friendly it is to build a query.</p>
<p>For some time it simply stood reverberating on my mind&#8230;</p>
<p><strong>The Rules Engine &#8211; An insight from Digital Marketing</strong></p>
<p>It was during the preparation of a Sitecore training course for Content Editors, targeting Digital Marketing features, that I first considered using the Sitecore Rules Engine for my purposes. Despite it is originally used for other things, such as Content Personalization or Event-triggered custom tasks, the experience was very close to what I was thinking. The way conditions and actions are chained is perfect for flexibility and is also very user-friendly.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/Rules.png"><img class=" size-full wp-image-267 alignnone" src="http://blog.peplau.com.br/wp-content/uploads/Rules.png" alt="Rules" width="721" height="526" /></a></p>
<p>That is actually perfect for my intents:</p>
<ul>
<li><span style="text-decoration: underline;"><strong>Rules</strong></span> would now be a way to save a data transforming pattern</li>
<li><span style="text-decoration: underline;"><strong>Conditions</strong></span> could be used to select and filter content</li>
<li><span style="text-decoration: underline;"><strong>Actions</strong></span> would be responsible for data processing and transformations.</li>
<li>They are also <span style="text-decoration: underline;">very easy</span> to code</li>
</ul>
<p>Then the idea started to flow out of my mind into a real tool&#8230;</p>
<h3>The Sitecore Rule Processor</h3>
<p>Available at the Sitecore Marketplace, <a href="https://marketplace.sitecore.net/en/Modules/S/Sitecore_Rule_Processor.aspx" target="_blank"><strong>Sitecore Rule Processor</strong></a> is the result of my efforts to automatize data transforming in Sitecore. After installed, when a Rule is selected at the Content Editor an icon is shown.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/3-Processor-Icon.png"><img class=" size-full wp-image-270 alignnone" src="http://blog.peplau.com.br/wp-content/uploads/3-Processor-Icon.png" alt="Processor Icon" width="617" height="129" /></a></p>
<p>When clicked, it brings up a window to process the rule, where users can easily filter items that matches the rule&#8217;s conditions, then execute their actions against all or some of the items:</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/4-Set-Root-and-Bring-Results.png"><img class=" size-full wp-image-271 alignnone" src="http://blog.peplau.com.br/wp-content/uploads/4-Set-Root-and-Bring-Results.png" alt="Set Root and Bring Results" width="838" height="384" /></a></p>
<p>This way any user can visually build queries to retrieve items, and setup actions to transform them.</p>
<p>The module comes with a series of custom Actions, to increase the number of things a user can do to process and modify items, such as:</p>
<ol>
<li>Add a version to the item at a certain language;</li>
<li>Change the item&#8217;s template;</li>
<li>Copy, Move or Clone items to a certain path;</li>
<li>Delete items;</li>
<li>Empty an item&#8217;s field;</li>
<li>Log a message with info taken from the item;</li>
<li>Publish the item;</li>
<li>Replace a string in a field of the item;</li>
<li>Replace a string in an item&#8217;s name;</li>
<li>Run a script;</li>
<li>Serialize the item;</li>
<li>Set a value at an item&#8217;s field;</li>
<li>Set the value of an item&#8217;s field as the value of another item&#8217;s field;</li>
<li>Set the value of an item&#8217;s field as the ID of another item;</li>
<li>Set a workflow state.</li>
</ol>
<p>I still have some useful actions left to do in my backlog, which will expand even more the value of this module.</p>
<h2>Real life experience: existent actions</h2>
<p>Then it finally happened: the next &#8220;monkey-job&#8221; were lurking at the clouds, being parachuted on me without a notice. One of our projects came with this demand: a &#8220;news article&#8221; template had some of its look and feel updated, and it imposed the need to replace some content of a Richtext field in all items (there were around 200 items at the repository). We had to replace all entries of class=&#8221;old-style&#8221; to our new class=&#8221;new-stype&#8221;.</p>
<p>My rule was then composed by:</p>
<ul>
<li><strong>Conditions</strong>
<ul>
<li>Where template=&#8217;News Article&#8217;</li>
</ul>
</li>
<li><strong>Actions</strong>
<ul>
<li>Replace a string in a field of the item
<ul>
<li>Replace class=&#8221;old-style&#8221;</li>
<li>By class=&#8221;new-style&#8221;</li>
<li>At field &#8220;Body&#8221;</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>&nbsp;</p>
<h2>Real life experience: a custom action</h2>
<p>The above covered part of our needs, unfortunately some replacements were not that straight-forward. For instance, some of the markup had to be replaced by different tags. In our case, some tables inserted by the client had to be replaced by better formed &lt;figure&gt; tags.</p>
<p>This demanded the creation of a custom action, which would parse the HTML and apply replacement logic at its Document Object Model, then save it back to the item. To learn how to create a custom action, please check <a href="http://www.sitecore.net/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2012/03/implement-a-rule-action-to-remove-an-insert-option-in-the-sitecore-aspnet-cms.aspx" target="_blank">this article from John West</a>.</p>
<p>My rule ended up very similar to the previous:</p>
<ul>
<li><strong>Conditions</strong>
<ul>
<li>Where template=&#8217;News Article&#8217;</li>
</ul>
</li>
<li><strong>Actions</strong>
<ul>
<li>My custom action for DOM replacements</li>
</ul>
</li>
</ul>
<p>Please fell free to download and test the module (available on the Sitecore Marketplace <a href="https://marketplace.sitecore.net/en/Modules/S/Sitecore_Rule_Processor.aspx" target="_blank">at this link</a>), and expand it as you need. Also please let me know if you have questions or any feedback!</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/mass-data-processing-with-rules-and-actions-the-sitecore-rule-processor-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Rules to replace spaces by dashes in Sitecore 7.5 in 3 simple steps</title>
		<link>https://blog.peplau.com.br/replace-spaces-by-dashes-using-rules-in-sitecore-7-5/</link>
		<comments>https://blog.peplau.com.br/replace-spaces-by-dashes-using-rules-in-sitecore-7-5/#comments</comments>
		<pubDate>Tue, 28 Apr 2015 22:30:19 +0000</pubDate>
		<dc:creator><![CDATA[Rodrigo Peplau]]></dc:creator>
				<category><![CDATA[Actions]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Rules]]></category>

		<guid isPermaLink="false">http://blog.peplau.com.br/?p=201</guid>
		<description><![CDATA[<div class="lr_horizontal_share" data-share-url="https://blog.peplau.com.br/replace-spaces-by-dashes-using-rules-in-sitecore-7-5/"></div>In this article I show how to use rules to rename items so, every time an item is saved, spaces gets replaced by dashes. Advantage of using rules is that you can visually setup different kind of conditions, without having to hardcode them at your code. 1) Create the Action that triggers the item renaming In your master [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In this article I show how to use rules to rename items so, every time an item is saved, spaces gets replaced by dashes. Advantage of using rules is that you can visually setup different kind of conditions, without having to hardcode them at your code.</p>
<h3>1) Create the Action that triggers the item renaming</h3>
<p>In your master database, add your new <strong>Action</strong> using the template /sitecore/templates/System/Rules/Action. In this case I&#8217;m using the path /sitecore/system/Settings/Rules/Definitions/Elements/Script because the <strong>Script</strong> Element Folder is already referenced by the <strong>Item Saved</strong> rules.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/Creating-the-action.jpg"><img class="alignnone wp-image-204 " src="http://blog.peplau.com.br/wp-content/uploads/Creating-the-action.jpg" alt="Creating the action" width="797" height="308" /></a></p>
<p>The <strong>Type</strong> field must point to your class that handles the item renaming (use the format &#8220;<em>Namespace.ClassName, Assembly</em>&#8220;)</p>
<h3>2) Create the class that executes the item renaming</h3>
<p>This is where your code for checking and renaming the item gets executed (parameter &#8220;ruleContext.Item&#8221; brings the item being saved).</p>
<pre>using Sitecore.Diagnostics;
using Sitecore.Rules;
using Sitecore.Rules.Actions;

namespace BusinessLayer.Rules.Actions
{
    public class AddHyphensToItemName : RuleAction where T : RuleContext
    {
        public override void Apply(T ruleContext)
        {
            Assert.ArgumentNotNull(ruleContext, "ruleContext");
            var obj1 = ruleContext.Item;
            if (obj1 == null)
                return;

            // Scape if no space is at the Name
            var itemName = obj1.Name;
            if (!itemName.Contains(" "))
                return;

            // Rename the item
            itemName = itemName.Replace(" ", "-");
            obj1.Editing.BeginEdit();
            obj1.Name = itemName;
            obj1.Editing.EndEdit();
        }
    }
}
</pre>
<h3>3) Create the Rule to execute the Action above</h3>
<p>Add your new <strong>Rule</strong> using the template /sitecore/templates/System/Rules/Rule, then edit your rules.</p>
<p><a href="http://blog.peplau.com.br/wp-content/uploads/Rule-to-rename.jpg"><img class="alignnone wp-image-214 " src="http://blog.peplau.com.br/wp-content/uploads/Rule-to-rename.jpg" alt="Rule to rename" width="818" height="341" /></a></p>
<p>In this case what I&#8217;m doing is:</p>
<ul>
<li>Including everything under &#8220;/sitecore/content/Site/Home&#8221; &#8211; because I just want to apply this rule to the items under my Homepage;</li>
<li>Skipping items that doesn&#8217;t have a layout &#8211; We don&#8217;t mind if items without renderings has spaces;</li>
<li>Calling the action &#8220;Add Hyphens To Item Name&#8221; for the matching Items.</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://blog.peplau.com.br/replace-spaces-by-dashes-using-rules-in-sitecore-7-5/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
