Tag Archives: sitecore

Sitecore CMS

Sitecore Developer Toolbox Chunk

Sitecore Developer Toolbox Module for Sitecore 7.2+

Have you ever tried to remember what the URL is to the Show Config or the Cache page in your Sitecore instance when using the Administration Tools?

Did you know that there is a Database Browser that the old-schoolers use to Brute Force work they need to get done with Sitecore OR an XPath building tool you can lean on to help you with Sitecore queries?

If you don’t know what I am speaking of, I am eluding to some old-school tools that can be very useful for every day administration and development. For example, the Administration tools page with links to all kinds of tools from the backend, XPath Builder to help you write and validate queries/fast queries, and File Explorer to help you view Website folders/files on the Sitecore instance you have the Sitecore Developer Toolbox (SDT) installed on. When you install the Sitecore Developer Toolbox, you get quick access to these tools via the Developer tab in the Content Editor.

Here is a look at what the module will add to your Content Editor Contextual Ribbon:

Sitecore Developer Toolbox Chunk

Sitecore Developer Toolbox – Chunk

Administration Tools:

Sitecore Developer Toolbox Admin Tools

Sitecore Developer Toolbox – Admin Tools

XPath Builder:

Sitecore Developer Toolbox XPath Builder

Sitecore Developer Toolbox – XPath Builder

File Explorer:

Sitecore Developer Toolbox File Explorer

Sitecore Developer Toolbox – File Explorer

Here is the link to the module on the Sitecore Marketplace: https://marketplace.sitecore.net/en/Modules/S/Sitecore_Developer_Toolbox.aspx

If you like the module please recommend to the community, provide a rating, and/or review. Thanks and happy coding!

How To Setup, Configure, and Connect to xDB Cloud 2.0 – Part 1

In this post, I am going to run through my experience of setting up, configuring, and connecting to xDB Cloud 2.0. However, this is going to be a multi-post, because there are some steps that you need to take place so you can have the xDB Cloud set provisioned before you can connect. Once we get through the initial setup and provisioning by Sitecore, we will  go a little deeper on the connection that may need to take place depending on your environment.

First, I started my journey off by taking a look at some basic documentation on xDB Cloud and realized that I needed to use Version 2.0 as seen below, since the agreement was signed before July 21st:

Use Version 2 Instead of Version 1

Use Version 2 Instead of Version 1

Once I knew I needed to work with Version 2, I started looking through some documentation on Version 2 specifically here. When looking through the overviews, I needed to find out what xDB Cloud Set was compatible with my version of Sitecore, which is Sitecore 8.1 rev.160302 (Update 2). The xDB Cloud Service Compatibility Tables can be found here. I see that my version is supported for creating new xDB Cloud Sets and keep on trucking.

I move on to the “Connect to xDB Cloud 2.0” documentation. My Prerequisites are met so my next step is to “Request the xDB Cloud Customer Set” by putting in a Sitecore Support ticket with the following information:

  • License ID (Sitecore License ID & xDB License ID)
  • Deployment ID (This is the name you want to give to the set i.e. “companynameprod1”)
  • Sitecore Version (Sitecore 8.1 rev.160302 (Update 2)
  • Preferred Location (West US)

Then I waited for Sitecore Support to get back to me with the connection strings, and reporting service settings.

In Part 2, we will take a look at making the connections, and any other configurations that may need to take place to connect to your xDB Cloud set.

jQuery UI AutoComplete

jQuery AutoComplete using MVC with Lucene Index Computed Fields in Sitecore 8.1

In this post I am going to give an example of how to wire up suggestive search, otherwise known as AutoComplete, using the jQuery UI when using ASP.NET MVC along with Lucene Computed Index Fields in Sitecore 8.1.  An AutoComplete is as quoted from jQuery UI, “Enables users to quickly find and select from a pre-populated list of values as they type, leveraging searching and filtering“.

I started this off by working through the examples out of the most recent book put out by Phil Wicklund and Jason Wilkerson, Professional Sitecore 8 Development.  If you haven’t read this book, get it! It is filled with a lot of knowledge that you can add to your toolbox. I started with some basic examples from that book, and modified to get what I needed to meet my requirements for this task.

My requirement for this task was to create an AutoComplete that had a First Name and Last Name. The problem is that in my indexes they are stored as 2 separate fields in Lucene, as you will see below:

<field fieldName="first name" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
   <Analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
<field fieldName="last name" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
   <Analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />

In order for me to bring them both together in my AutoComplete I created a Computed Index Field. A Computed Index Field is a custom field that stores data in Lucene that is calculated at index time versus on the fly. I needed to query a full name not a first name field AND a last name field. Below is the code to create a Computed index Field called FullNameField.cs:


using System;
using Sitecore.ContentSearch;
using Sitecore.ContentSearch.ComputedFields;
using Sitecore.Diagnostics;
namespace SitecoreSandbox.Website.Search.ComputedFields
    public class FullNameField : IComputedIndexField
        public string FieldName { get; set; }
        public string ReturnType { get; set; }
        public object ComputeFieldValue(IIndexable indexable)
            Assert.ArgumentNotNull(indexable, "indexable");
                var indexItem = indexable as SitecoreIndexableItem;
                if (indexItem == null)
                    return null;
                var item = indexItem.Item;
                if (item != null)
                    return $"{item["First Name"]} {item["Last Name"]}";
            catch (Exception ex)
                Log.Error($"An error occurred when indexing {indexable.Id}: {ex.Message}", ex, this);
            return null;

Now, that I have my Computed Index Field, I need to add it to my index. First, I added my field to the fieldmap>fieldnames node to be included in the index:

<field fieldName="full name" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
   <Analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />

Then, I added my Computed Index Field to the documentOption>fields node to be included as a Computed Index Field:

<field fieldName="full name" storageType="YES" indexType="UNTOKENIZED">SitecoreSandbox.Website.Search.ComputedFields.FullNameField, SitecoreSandbox.Website</field>

You will notice that I added in indexType=”UNTOKENIZED” and that is because I want the value to not be split up. For example, if the name is John Doe, I want the results to come back as “John Doe” (UNTOKENIZED) versus “John” or “Doe” (TOKENIZED).

Now that my index is set up with my “full name” Computed Index Field all I need to do now is publish out to my Website folder and re-index. Once, I re-index I can see my field with the full names now being stored. I can easily view my index using LUKE – Lucene Index Toolbox, which I highly recommend, and it’s free. Below you will see that full names are left out for privacy purposes but you can see the field IS being indexed by Lucene and I assert to you the full names are there:

Luke (Lucene Index Toolbox)

Luke (Lucene Index Toolbox)

After verifying in Luke that my full names are being indexed, I added my new field to my PeopleSearchResultItem class so I can start using in code:

[IndexField("full name")]
public string FullName { get; set; }

Next. I created my interface for what is going to be used to implement my Search Service:


using System.Collections.Generic;
namespace SitecoreSandbox.Website.Search.AutoComplete
    public interface ISearchService
        IEnumerable<string> GetSearchSuggestions(string searchTerm);

Then, I implemented my Interface in my Search Service class:


using System.Collections.Generic;
using System.Linq;
namespace SitecoreSandbox.Website.Search.AutoComplete
    public class SearchService : ISearchService
        private readonly SearchManager _searchManager = new SearchManager();
        /// <summary>
        /// Gets the search suggestions from the computed index field for full name
        /// </summary>
        /// <param name="searchTerm"></param>
        /// <returns></returns>
        public IEnumerable<string> GetSearchSuggestions(string searchTerm)
            var suggestions = new List<string>();
            var results = _searchManager.GetNamesByLetters(searchTerm);
            if (!results.Any())
                return suggestions;
            suggestions.AddRange(results.Select(result => result.FullName));
            return suggestions;

The GetSearchSuggestions method will make a call to my SearchManager class where my Lucene search logic is taking place and return me my results. In this case, I needed to pass in letters as the user types to return me back my results for my AutoComplete. The GetNamesByLetters method is seen below:

/// <summary>
/// Gets the the names with letters used with AutoComplete
/// </summary>
/// <param name="letters"></param>
/// <returns></returns>
public List<PeopleSearchResultItem> GetNamesByLetters(string letters)
    var searchIndex = ContentSearchManager.GetIndex("people_index");
    using (var context = searchIndex.CreateSearchContext())
        return context.GetQueryable<PeopleSearchResultItem>()
            .Where(x => x.FullName.Contains(letters)).ToList();

Now, that my logic is in place to return my results I just need to set up my Controller to handle the post and my View to make an AJAX call to the AutoComplete function in the jQuery UI. Below is the Controller logic:

private readonly SearchService _searchService = new SearchService();

public JsonResult GetSuggestions(PeopleSearchViewModel viewModel)
    if (!string.IsNullOrWhiteSpace(viewModel?.SearchTerm))
        return Json(_searchService.GetSearchSuggestions(viewModel.SearchTerm));
    return Json(new {});

Below is the jQuery code to handle the event for my field that is utilizing the AutoComplete. I added this to my .cshtml file. Keep in mind that my main layouts are already using jQuery and referencing the library in code so I am not including that script here. Also, the jQuery UI <script> and <link> elements can be found on the jQuery UI website:

    $(function () {
            source: function(request, response) {
                    url: "/peoplesearch/getsuggestions",
                    type: "POST",
                    dataType: "json",
                    data: {
                        searchTerm: request.term
                    success: function(data) {
                        response(data.length === 1 && data[0].length === 0 ? [] : data);

The input text box HTML is below:

<input id=”people-name” placeholder=”Enter name” type=”text”>

The last thing I needed to do was just make sure that my route was set in the RouteConfig.cs file as such:

// Used with the AutoComplete for People Search
RouteTable.Routes.MapRoute("GetSuggestions", "PeopleSearch/GetSuggestions",
   new {controller = "PeopleSearch", action = "GetSuggestions"});

That’s all it takes to get the jQuery UI AutoComplete plug-in working for you to bring back results from your Lucene indexes. Happy coding!

Lucene Spatial Search Support Module

Lucene Spatial Search Support Module with Sitecore 8.1

I came across a need to implement a search based on zip code, latitude, longitude, and a radius. I quickly found out that this is a tall order in a short amount of time if implementing this type of functionality from scratch. However, the Lucene Spatial Search Support module came to the rescue…or did it? I am implementing a Sitecore 8.1 instance and it looks like the module was only good through 7.5 at the time of this post. There is an option to use SOLR Spatial Search Support module, and that IS updated through 8.1, but I didn’t have a driving need for SOLR on this project since my records being indexed were low in nature. So what is a Sitecore developer to do? Luckily, the Lucene Spatial Search Support module source code was available on GitHub, so I set out to get this module upgraded to 8.1. Time to get our hands dirty!

After cloning the repository from GitHub, I tried to build the project and there were many references missing, so I quickly grabbed a vanilla instance of Sitecore 8.1 rev. 160302 and added the references I needed to build the project. They are below:

Added to Sitecore.ContentSearch.Spatial project:

  • Sitecore.ContentSearch.dll
  • Sitecore.ContentSearch.Linq.dll
  • Sitecore.ContentSearch.Linq.Lucene.dll
  • Sitecore.ContentSearch.LuceneProvider.dll
  • Sitecore.Kernel.dll
  • Sitecore.Logging.dll

Added to Sitecore.ContentSearch.Spatial.DataTypes project:

  • Sitecore.ContentSearch.dll
  • Sitecore.Kernel.dll

I then had a build issue in this constructor in the LuceneSearchWithSpatialContext.cs:

protected LuceneSearchWithSpatialContext(ILuceneProviderIndex index, CreateSearcherOption options = CreateSearcherOption.Writeable, SearchSecurityOptions securityOptions = SearchSecurityOptions.EnableSecurityCheck)
: base(index, options, securityOptions)
Assert.ArgumentNotNull(index, "index");
this.index = index;
this.settings = this.index.Locator.GetInstance();

The Sitecore community never fails, and I found this on the Sitecore Stack Exchange where another developer simply commented out this constructor. I did the same and rebuilt the project but was missing a reference to a Sitecore.Abstractions.dll:

Sitecore.Abstractions Reference Missing

Sitecore.Abstractions Reference Missing

After adding in the Sitecore.Abstractions.dll to the Sitecore.ContentSearch.Spatial project, my project was successfully building. So I added this to the list of project references in addition to what was listed above:

Added to Sitecore.ContentSearch.Spatial project:

  • Sitecore.Abstractions.dll

Now it was time to make sure that the Sitecore.ContentSearch.Spatial.config was configured properly for 8.1. To my joy, it looks like there is a .config setup for version 8 that is disabled when I pulled from GitHub. I disabled Sitecore.ContentSearch.Spatial.config and enabled Sitecore.ContentSearch.Spatial.v8.config. Next, I added in my template criteria for my locations with the Template ID, LatitudeField, and LongitudeFields and then modified the index to use “sitecore_master_index” since I am testing this out locally and in live mode.

I added in the following .dll’s and .config file to the project I am working on that needs the spatial search feature:

  • Lucene.Net.Contrib.Spatial.dll
  • Sitecore.ContentSearch.Spatial.DataTypes.dll
  • Sitecore.ContentSearch.Spatial.dll
  • Spatial4nCore.dll
  • Sitecore.ContentSearch.Spatial.v8.config

After publishing my files and testing out, I got an error that said, “Current Index is not configured to use Spatial Search.

After some research, I realized that my index was set to use the wrong index earlier in code. Not only that, but one that wasn’t setup properly to for spatial search at all. After pointing to the correct index, publishing from Visual Studio, and then rebuilding my “sitecore_master_index” I was getting results back.

As I stated earlier, you can also perform spatial search with SOLR. If you have a client that has this type of environment (which is most right!?), I would take a hard look at SOLR for your client’s search provider.

You must use Solr if you have a scaled environment. This means you have:

  • two or more content delivery servers
  • two or more content authoring severs
  • separate servers for email, processing, reporting and publishing

Solr supports calls over HTTP(S) which means that the indexes are available to all servers in the environment that require it (content management and processing servers).

Big shout out to Ahmed Okour for the help that he provided for questions I had during the process. Happy coding!

Typical Roles and Permissions Setup for Sitecore 8+

When initially setting up the roles and permissions for your new Sitecore 8+ site, you may be asking yourself what roles do I need for my organization typically? When you use the Role Manager to create your roles you may be asking yourself what roles do I need to create and what roles do they need to be a Member Of so my that role can have the correct functionality in Sitecore to perform their job? You also may be asking what permissions do I need to give to these roles in Security Manager?

Below is a typical setup seen in a lot of companies that are using Sitecore 8+. Keep in mind that the business needs will dictate what roles you may have and also that someone may be in more than one role, one person may be all roles, or there may be a separate person for each role. It’s all up to the business and it’s all customizable to the business needs.

Typically, you will want to have a couple of Administrators on the site so someone can always get in and perform Administrative type of duties if someone on vacation or out for some reason. This is as simple as choosing your power Sitecore user at the company and then typically Developers have Administrator access as well. Some will choose to create a Global SItecore Administrator role, which is a member of all roles. This works fine too. The added benefit, if needed, is that this role DOES NOT bypass workflows like the Administrators account does. In addition, it’s easy to see who your administrators are in one role.

As for everyone else that is non-designated power user or a developer, they will fall into one of these typical role buckets. Examples are for a company called “Sitecore Sandbox”:

SS Content Editor:

Typically, the Content Editors are the marketing or web team that are going to be in charge of editing content in Sitecore.

Member Of:

  • Author
  • Designer
  • Experience Editor
  • Sitecore Client Translating

SS Content Publisher:

Typically, the Content Publishers are the marketing team managers that will make final decisions to approve the content and then publish it live to the web.

Member Of:

  • SS Content Editor
  • Sitecore Client Publishing

SS Marketing Analyst:

Typically, the Marketing Analysts are the marketing team people who will be analyzing the effectiveness of the marketing efforts and possibly putting together reports for higher ups.

Member Of:

  • Analytics Reporting
  • Analytics Advanced Testing
  • Analytics Management Reporting
  • Analytics Content Profiling
  • Analytics Testing
  • Analytics Personalization

SS Marketing Administrator:

Typically, the Marketing Administrators are the marketing management team that has all the functionality of the Marketing Analysts but can also edit content as well.

Member Of:

  • SS Content Editor
  • SS Marketing Analyst

The permissions can be setup easily by going into the Security Editor and selecting the role you want to give permissions to. You will want to give read/write/rename/create/delete/administer permissions based on the role, but typically read/write/rename/create/delete is sufficient.

Now, when you setup the users in those roles they may not see what all they have access to UNLESS they check the “Hidden items” checkbox in the Views tab–>View chunk in the Contextual Ribbon. Make sure they know to do this or you may have them coming back to you with questions and you may be scratching your head on why they can’t see the items they need access to. Happy coding!

10 Steps to Setup MongoDB as a Windows Service with Sitecore 7.5+

If you are doing development work with SItecore 7.5+ and beyond, you may want to set up MongoDB to connect to Sitecore locally or on your DEV, QA, STAGING servers. This is just a brief tutorial on the steps needed to set up MongoDB on your as a service, and then validate that it is connected to your local SItecore instance via RoboMongo. This post relates to Sitecore versions 7.5 and up.

  1. Download the MongoDB installer here: MongoDB
  2. Install using the Custom installation so you can change the default location. Typically, I put all my projects and websites on a separate non-operating system drive such as a D: drive. I installed to D:/MongoDB/.
  3. In the folder “MongoDB” create a folder called “data” and inside that folder, create a folder called “db”. These will not be created for you during install so you will need to create them.
  4. Create a new .config file in the “MongoDB” folder and name it “mongo.config”. This is where we will store the configurations for MongoDB.
  5. Copy/paste the configuration into the new “mongo.config” file and modify to your specific workstation:
  6. Next, look in the “MongoDB” folder. You may need to create the “log” folder and put a “mongo.log” file in the that folder for the next line to succeed if it was not created during the installation of MongoDB.Now, install MongoDB as a Windows Service, so it will start every time you start-up Windows and stay running. Open up a Command Prompt (Run As Administrator) and type in the following (modify if needed for your filepaths):
    D:\MongoDB\bin\Mongod.exe --config D:\MongoDB\mongo.config --install
  7. This will create a new windows service called MongoDB. Now, to start the service simply type in the following:
    net start MongoDB
  8. You can use GUI tools like RoboMongo to work with Mongo data. Typically, Sitecore connections strings are already setup OOTB so you really just need to set up MongoDB. If you want to verify that your data is being stored then simply download RoboMongo. The example below is using MongoVUE, but I don’t recommend as it has been problematic in the past to download from their website. However, the process is basically the same for RoboMongo.
  9. Once installed you simply click the green plus icon to add a connection, then type in the name of the connection, and the server. Since, you this is on your local workstation you will use localhost OR then save.

    Add Connection In MongoVUE

    Add Connection In MongoVUE

  10. Now you should be able to see your connection listed in MongoVUE, and if you expand the connection you will see your tables and data being captured from Sitecore.

    Sitecore Experience Data Is Connected

    Sitecore Experience Data Is Connected

During the making of this blog post, I referred to these blog posts below, which helped me to achieve setting up my local developer workstation to run MongoDB as a Windows Service and connect it to a Sitecore 7.5+ instance. One last thing, if you are using SIM (Sitecore Instance Manager), you can also perform all the above in one click. Happy coding!

Setting up MongoDB on Developer Machine:

Install MongoDB on Windows:

Helpful Tips to Troubleshooting Sitecore Issues

Below is a LIVING list of helpful troubleshooting tips to fixing Sitecore issues.  Meaning, these are tips that Sitecore developers typically will run through before going to the Sitecore Community and/or Sitecore Support.  If a tip is not in this list, feel free to comment and I will add it to this running list.

These are tips, in no order, that might be helpful to aid you in determining the root of an issue and coming to resolution:

  • Check the Sitecore Logs for errors located in the Data/Logs folder.  It’s a best practice to have the Data folder as sibling to the Website folder and not inside the Website folder.
  • Using Chrome’s Web Developer tool you can check the Network tab, or in Firefox Firebug use the Profile button to see if anything is failing with when being loaded or events are firing etc.
  • See if the issue is browser specific by using different browsers (IE, Firefox, Chrome).
  • Debug with Visual Studio for ASP.NET/C# issues.
  • Debug with Firebug/Chrome Web Developer tool for JavaScript type of issues.
  • If .dll issue take a look at the .dll in .NET Reflector, or similar reflection tool, and see what the code is setup to do.  This might lead you in the direction of the issue.
  • Try clearing the cache at http://[yoursite]/sitecore/admin/cache.aspx
  • Check to make sure your includes are being included post .config build at http://[yoursite]/sitecore/admin/showconfig.aspx
  • Try recycling the app pool for the website.
  • If missing files/items see if a previous package was installed and reinstall to pick up the files/items.
  • Is the issue environmental, meaning works in one Sitecore instance locally, but not in staging/production? If so, what could be the difference in files/items/configuration you can compare that will give you direction to solve the problem. You may need to use a tool like Beyond Compare, or similar tool, to diff some files to get to the root of the issue.

Thanks in advance for any helpful tips to help out the Sitecore community! Happy coding!