Friday, 18 July 2014

How to customize [No Text In Field] message of Sitecore Page Editor?

Hello Sitecore busy bees! How's your Sitecore Journey going on?
Recently one of  the regular Sitecore Journey readers (Varun Shringarpure) raised a small but good to know question. Sitecore Journey was awared about the answer of this question, but was not able to recall. Finally Sitecore Journey found the answer and to keep this answer handy, thought to document it via blog.

User wants to customize the [No Text In Field] message of page editor in Sitecore. Those who don't know where and when this message comes, the answer is - whenever any Sitecore item field is blank and that page is accessed in page editor mode then you will see [No Text In Field] message as mentioned below.

Solution is very simple until you find it :)
I think most of you will agree with me that, the best thing about Sitecore is - it's flexibility.
Sitecore is so flexible that you can customize almost everything. This customization can be done either hooking your code or updating settings.

Let's move on and see how can we customize [No Text In Field] message, switch to core database and go to /sitecore/content/Applications/WebEdit/WebEdit Texts item.

Now change Default Text field to customize the message.

Here is the result:

Wednesday, 9 July 2014

Cascading (Auto-Populate) MultiList Field in Sitecore

Hello Sitecore Buddies!
Thank you for accompanying Sitecore Journey. Feeling blessed to have such expert readers!

Sitecore Journey is incomplete without all of you Sitecore expert readers!

Well, Sitecore Journey is here today to share one of the unique requirements. Let's see today's scenario which will illustrate how to create custom field type in Sitecore.

There was a requirement to auto-populate one Sitecore Multilist field based on another Multilist Field in Sitecore - same like cascading dropdownlist of Ajax Toolkit in ASP.NET.

Here's the video which illustrates this requirement:

Many of you have already thought about how to achieve this requirement, yes you are correct - you need to create custom field type in Sitecore. So let's create custom Multilist field type control which will populate/bind second Multilist field based on first Multilist's selected values.

1) Create separate class library project in your Sitecore solution (if you have already such project then you can of-course use that).

2) Add a CustomMultilist class in this project, inherit CustomMultilist class from MultilistEx.

Below is complete code snippet of CustomMultiList field control:
using Sitecore.Data.Items;
using Sitecore.Shell.Applications.ContentEditor;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sitecore.Extensions
    public class CustomMultiList : MultilistEx
        protected override void DoRender(System.Web.UI.HtmlTextWriter output)

        private void ExcludeItems()
            Item i = Sitecore.Context.ContentDatabase.GetItem(base.ItemID);

            Sitecore.Data.Fields.MultilistField multilistField =i.Fields["MultilistField1"];
            Item[] selectedItems = multilistField.GetItems();
            StringBuilder sbItemId = new StringBuilder();
            foreach (Item selectedItem in selectedItems)

            if (sbItemId.Length > 0)
                this.Source = sbItemId.ToString().Remove(sbItemId.Length - 1, 1);
3) Compile project and copy Sitecore.Extenstions.DLL in your [Sitecore Website Root]/bin directory.

4) Add below line in web.config of your Sitecore instance.
<source assembly="Sitecore.Extensions" mode="on" namespace="Sitecore.Extensions" prefix="contentExtension"></source> 

5) Create a new fieldtype (e.g. CustomMulitList field) in core database as shown in below image:

6)  Now go to your item template where you want to assign this CustomMultiList field. You should assign this CustomMultiList field to only that field which you want to auto-populate based one another MultiList field.

Enjoy your Sitecore Journey!

Tuesday, 8 July 2014

Sitecore Multilist Restriction

How are you my Sitecore Friends? How's your Sitecore Journey going on?
I am here again to share one more small but good to know point about Sitecore.

Many things in Sitecore are given by default, but as we are dealing with complex things in our day to day life - we never spend time to look at whether that functionality is given by our Sitecore platform or not and start thinking about custom implementation.

One such scenario is - How to restrict number of selected items in Sitecore Multilist field?

It is very simple and straight forward.

You simply need to go to your template where "Multilist Field" is defined, then add validation expression in "Validation" field as per your need. In my case, validation requirment was to allow maximum three items to be selected. Hence I added validation expression - ^(\{[^}]+\}\|?){0,3}$

Also add user friendly message in "Validation Text" field which will be shown to user whenever your field does not meet validation criteria.

Below screenshots will help you to understand it easily.

You are interested in this post, but don't have time to implement and check. Then watch this video which will show you exact implementation.

Have a happy Sitecore Journey!

Wednesday, 2 July 2014

How To Create Package of Sitecore Users and Roles?

Friends, as I promised in my last post that you are going to learn few more things from Sitecore journey. So are you ready to learn one more topic about Sitecore?

Here you go...

When your Sitecore project is ready to deploy, how do you move your Sitecore items to stage/live environment? You will say - it's simple, create package in Sitecore and install on live/stage Sitecore instance. Yes, you are correct.

But have you come across a situation where you want to move users from you development Sitecore instance to stage/live Sitecore instance?

Well, I have come across such situation and surprisingly I didn't find how to package users in Sitecore? Then I thought we can move users from development Sitecore instance to stage/live Sitecore instance using serialization feature only.

I found that other Sitecore developers are also thinking like me - that we need to serialize users as we cannot package users.

But when I asked this to one of my colleague who is Sitecore Expert (Sheetal Jain - Sitecore MVP), I came to know that Sitecore do have facility to package users/roles. The most surprising thing was - "I have visited that Sitecore window thousands of times, but have never noticed that option to package users/roles"

If you have already noticed and used this option, then one like from my-side!
If you haven't, then you will give one like to me for this post :)

Follow these steps to package users/roles in Sitecore:

You can select multiple users by holding CTRL (control) key.

After installing Users and Roles package you will find that the passwords of all these users are not working. So you need to set password of these users as well.

Please refer below Sitecore knowledge article for transferring passwords of packaged users.

Hope this post may help you in your Sitecore Journey!