Surendra Sharma

Surendra Sharma

Search This Blog

Thursday, July 18, 2019

Get all Sitecore page items only by using PowerShell script

We got the requirement to create report of all the items which are accessed by URL i.e. report of all page items.

A simple solution, for this, is to check is rendering exist on the an item or not?
If rendering exists, it means layout and components are assigned on that item. If rendering is empty, it means no layout or no component exists on that item.

You can write a C# code for generating such report but I think PowerShell is the best way to do this.

Here is the one line script for the same

Get-childItem -Path "master:\sitecore\content\home" -Recurse | Where-Object { ($_.__Renderings -ne "") } | Show-ListView -Property id, name, itempath

With this one line you can imagine the power of PowerShell. 

I strongly recommend to brush up your scripting skill.

Friday, July 12, 2019

Webinar on Voice based search with Sitecore GraphQL

I conducted webinar on "Voice based search with Sitecore GraphQL" for SUGNCR group today.

Sample code for this demo is available at

 Watch recording for more details

Friday, July 5, 2019

Fixed: Rebuild Reporting Database failed in Sitecore

We are using Sitecore 8.2 and our analytics data is stored in MongoDB database. Its size is around 50 GB.

From few days, we were not getting data in Sitecore analytics reports so we decided to rebuild reporting database.

We started rebuilding activity, but it fails on 8th days. We tried again, and same thing happen and failed on 8th days.

We started to investigate why its failing specially on 8th days?


There is a config setting <TaskEntryAfterLife> in file "Sitecore.Analytics.Processing.config" which by default set for 8 days. 

  Specifies the minimum time a task entry (and all associated data structures) is kept in the task queue after
  the task has executed.
  Default: 8.00:00:00

We changed its entry for 15 days as

  Specifies the minimum time a task entry (and all associated data structures) is kept in the task queue after
  the task has executed.
  Default: 8.00:00:00

After this we again started rebuilding activity and this time it works fine and completed the task on 10th days.

Now we are getting missing data in Sitecore analytics reporting sections.

I hope it helps you to fix the similar issue.

Stay tuned for more such tips and tricks.

Monday, June 24, 2019

Screenshot module for Sitecore

Happy to share that my "Screenshot" module for Sitecore is published on Marketplace. One can take screenshot of current Sitecore Content and Experience Editor easily by using this module.

Download and enjoy this free module.

Love to hear your comments and feedback.

Monday, June 17, 2019

Total Page View Crossed 250000

I am very excited to share that today my Sitecore blogpost crossed magical number 250,000+ page view all time.

Thanks for all the visitors and followers. I started this blog to share my ideas and findings with rest of the world. I hope this help people around the world in some useful and meaningful ways.

I will continue to share my real life experiences with you all in same way.

Stay tuned for some upcoming cool ideas ,implementations and sample code.

Pageviews all time history
Pageviews all time history

Thursday, June 13, 2019

Week of AI

In May 2019, Microsoft India scheduled "Week of AI" virtual workshop series for 5 days. I have attended all the sessions and participated in all the quiz series. Happy to share that today I got my Microsoft "Week of AI" Azure Ninja Cat badge.

Wednesday, June 12, 2019

Search in Sitecore JSS

Happy to share that SUGCON India 2019 videos are published on Youtube. I conducted session on "Search In Sitecore JSS". I am sharing here recorded session on the same.

Friday, May 24, 2019

Sitecore Smart Comment Analyzer using Microsoft Azure Text Analytics Service

Happy to share that I have created new Sitecore module "Smart Comment Analyzer using Microsoft Azure Text Analytics Service".

One can use this module on Product page or blog website pages to collect comments from visitors. These comments will be analyze for their sentiment score as positive or negative. All positive comments directly published on the website page while all the negative and abusive comments will be stored in external SQL database which further reviewed by Sitecore backend team for publish approval. 

Watch the video for more details. 

Tuesday, May 21, 2019


Happy to share that I have attended my first SUGCON INDIA conference in Bengaluru on 16-17 May. I conducted session on "Search in Sitecore JSS".

I met with lots of Sitecore developers who join this from different parts of India. I come to know about some cool ideas and implementation from their sessions.

Glad to saw few ex-colleagues as well after a long time.

I was lucky to win the Apple PowerBeats Wireless headphone in one of the lucky draw.

Hope to join the next SUGCON India 2020.

You can download my presentation on "Search in Sitecore JSS" from here.
Sharing few clicks from the conference. I hope you will enjoy these clicks

Friday, May 10, 2019

Coveo for Sitecore Developers exam certificate

Happy to share that I successfully cleared Coveo for Sitecore Developers exam.

Coveo for Sitecore Developers
Coveo for Sitecore Developers

Tuesday, May 7, 2019

Microsoft Build 2019

Happy to share that we have attended very informative Microsoft Build 2019 Event on May 6, 2019 at Microsoft Office, Gurgaon.

Microsoft Build 2019
Microsoft Build 2019 at Microsoft Office, Gurgaon

Friday, April 19, 2019

Image tagging in Sitecore using Microsoft Computer Vision

Happy to share that I have created a module to add tags automatically to new or existing media library image item in Sitecore using Microsoft Computer Vision.

Watch the video for more details. 

Wednesday, April 3, 2019

Fixed : Sitecore multilist with search not showing data

In my Sitecore instance, I was not getting data in "Semantics" multilist with search field under "Tagging" section in Home item. By default this field should show atleast one value "Test tag".

Solution :-

Simply rebuild your master index. After that you should get data in multilist with search field.

Multilist with search
Multilist with search

Sunday, March 24, 2019

Code : Get any attribute value from HTML string in C#

If you have HTML string in C# and you want to get any particular value of any attribute then you can use below function which refer Regex to get its value.
In below program I am extraing “src” attribute value of HTML “img" tag.

Input string : <img alt="" src="/MediaCenter/PublishImages/DSC_0134.jpg" width="150" style="border:0px solid" />

Output : /MediaCenter/PublishImages/DSC_0134.jpg


using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;

namespace Rextester
    public class Program
        public static void Main(string[] args)
            string s = "<img alt=\"\" src=\"/MediaCenter/PublishImages/DSC_0134.jpg\" width=\"150\" style=\"border:0px solid\" />";

            var srcs = GetSrcInHTMLImgString(s);
            Console.WriteLine(srcs[0]);//Output: /MediaCenter/PublishImages/DSC_0134.jpg

        public static List<string> GetSrcInHTMLImgString(string htmlString)
            List<string> srcs = new List<string>();
            string pattern = @"(?<=src="").*?(?="")";
            Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
            MatchCollection matches = rgx.Matches(htmlString);

            for (int i = 0, l = matches.Count; i < l; i++)
                string d = matches[i].Value;
            return srcs;

We can make this function more generic where we will pass any attribute name and get the value as

public static List<string> GetAttributeNameInHTMLString(string htmlString, string attributeName)
    List<string> attributeValues = new List<string>();
    string pattern = string.Format(@"(?<={0}="").*?(?="")", attributeName);

    Regex rgx = new Regex(pattern, RegexOptions.IgnoreCase);
    MatchCollection matches = rgx.Matches(htmlString);

    for (int i = 0, l = matches.Count; i < l; i++)
        string d = matches[i].Value;
    return attributeValues;

Calling this function as

string s = "<img alt=\"\" src=\"/MediaCenter/PublishingImages/DSC_0134.jpg\" width=\"150\" style=\"border:0px solid\" />";

var widths = GetAttributeNameInHTMLString(s, "width");
Console.WriteLine(widths[0]);   //Output : 150

var styles = GetAttributeNameInHTMLString(s, "style");
Console.WriteLine(styles[0]);   //Output : border:0px solid

Its a small function but very handy. 

To test it, you can use C# online compiler “.NET Fiddle” instead of creating console application in Visual Studio. Many times I am using these online tools for quick testing. 

Let me know if you have any better idea to get attribute value from HTML string.