5 Sitecore Interview Tips by Nilesh Thakkar

Are you looking for a change and preparing for an Interview OR Do you need any tips for Sitecore Interview?

If so, then you must watch this video before appearing for an Interview. I got a chance to have a quick chat with Nilesh about the interview tips and see what he says in the video.

Here are the Top 5 Tips shared by Nilesh Thakkar:

  1. Know More About Your Interviewer
  2. Show Your Problem Solving Skills
  3. Know How Sitecore Works Behind The Scenes
  4. Show Your Right Attitude
  5. How Do You Handle Conflicting Situation?

Happy Job Hunting!

Sitecore Watch Face | Google Wear OS

After buying Google Wear OS-powered smartwatch, an idea came to my mind to personalize the watch face with Sitecore logo.

As it’s round, a watch face will definitely fit the round dial.

Wear OS Watch Face App is now on the Play Store for you as well, if you are having Google Wear-OS powered smartwatch — go and check out this simply designed watch face.

Sitecore Watch Face

On your watch Play Store, search for Sitecore and you’ll find Sitecore Watch Face.

https://play.google.com/store/apps/details?id=com.nikkipunjabi.sitecorewatchfaces&rdid=com.nikkipunjabi.sitecorewatchfaces

If you know Android Development and would like to contribute, you are free to play around with the project.

https://github.com/nikkipunjabi/SitecoreWatchFace

The comment section is open for your suggestions/feedback. 🙂

Enjoy Sitecore Watch Face!  😉

Automate Sitecore Workflow Approval Process and Email Report

Automation is the key to tech. It is the process by which tasks which were previously done by humans, are performed entirely by machines. In this post, I shall take you through how to automate Sitecore Workflow Approval for a more efficient way of working.

Why do you need Auto Approve?

Every project has a different set of requirements, and one of the requirements I was tasked to do was to automate the Workflow approval process. You may think, what is the purpose of having a workflow if you want things to be approved automatically. Well, as mentioned earlier, there are different scenarios that may deem such a requirement necessary.

It is not because of the risk in approving content that may be incorrect. It is due to that fact that there are a lot of items in the workflow coming in from the translation agency and in order to verify the content, it requires physical approval to push on to Stage. The automation to be implemented here will help us to know that translations are coming in and send it to the respective content team member to verify. Once verification is done, then in one simple, a user can push it Live.

Read More

Sitecore and GatherContent Integration | Part-2 | Challenges and Solution

In an earlier post, I wrote an overview on Sitecore and GatherContent Integration Overview and the challenges we faced. In this post, you’ll see many other challenges that we faced with GatherContent and Sitecore Integration and how to crack them.

I got the source code of GatherContent Module thanks to the devs. It’s also available on GitHub.

We faced many challenges with it, but we managed to fix the issues one by one and get it to work. Some of them were fixed by the GatherContent Dev Team.

Most of the changes were done in GatherContent.Connector.SitecoreRepositories project.

Challenges:

  1. Different folder structure
  2. Zero-width space
  3. Blank space in GatherContent
  4. Sitecore General link, Number and Checkbox support
  5. Alt Text for Images
  6. Redirect Rule Issue

Read More

Sitecore Package Assistant | Sitecore Module

Hey Sitecore Devs,

This module is for you. It will help you track Sitecore items which you worked on and create a package of it easily. If you want to skip any item, you can just ignore it and that will never be tracked. This will be helpful when you are working on many items in the Sitecore and once you are done creating the module you can easily package it using Sitecore Package Assistant.

The idea for this module popped to Saad Ansari and he shared it via blog post: Sitecore Package Creator – The untracked/unpackaged changes while creating the packages

I took his views and started conversation with him for creating a module of his idea. We started one by one with the requirements and implimented this module.

Pre-requisite: This module works based on Sitecore PowerShell Extensions. So before you install this module it is must to have Sitecore PowerShell Extensions.

Download: Sitecore Package Assistant

Source Code: GitHub

This module will:

  • Track item on items created and saved.
  • It will show an icon in the gutter for the items which are getting track.
  • You can track/untrack any item once it is updated.
  • You can easily create the package of the items which have been tracked and on complete, the tracking is removed.

After installation, you’ll have to first enable Sitecore Package Assistant in the Sitecore Gutter.

Now, as you work on the Sitecore items, which ever items you have added/updated, you’ll start seeing an  icon. On hover, you’ll see a tool-tip: This item is being tracked by SPA. Click to untrack. You can click on the gutter icon and that item will be added as untrack item. You’ll see an  icon.

In case you don’t see the icon in the Sitecore Gutter. Open Sitecore PowerShell ISE, go to Settings and Rebuild Content Editor Gutter.

The details about the item track/untrack is logged at: /sitecore/system/Modules/Sitecore Package Assistant/SPA

Once you are done with your functionality in the Sitecore, you can right click on any item and create a package of tracked items using Sitecore Package Assistant. It will give you an option to Download the Package.

This will be helpful for the Devs, so that you don’t miss any item while creating a Sitecore Package.

You can also refer Saad Ansari’s blog: Sitecore Package Assistant — Where you can know more about this module in very detail and benefits of it.

There is much more that can be done. Your suggessions/feedback/ideas are worth sharing in the comments below.

Happy Sitecoring!

Sitecore Gutter using Sitecore PowerShell Extentions

Hey Sitecore folks,

Do you know that you can create Sitecore Gutter using Sitecore PowerShell Extensions?

Yes, it’s easy to create Sitecore Gutter using Sitecore PowerShell Extensions. We’ll see how you can easily create gutter and trigger an event on click of it.

Let’s take an example of multi-linqual site in the Sitecore. For example, Content Authors switch the language to Japanese then in the Sitecore gutter we’ll show an add icon for the items which are not having the Japanese version. I will write a simple PowerShell Script which will show Add icon if an item doens’t have any version in the context language.

<#
    .NAME 
        This item does not have any version in the current language
 
    .SYNOPSIS
        Renders gutter indicating an item doesn't have any version in the current language.
      
    .NOTES
        Nikki Punjabi
#>

$currentItem = $item = Get-Item . -Language $SitecoreContextItem.Language.Name -ErrorAction SilentlyContinue

if($currentItem -eq $null) {
    
    $gutter = New-Object Sitecore.Shell.Applications.ContentEditor.Gutters.GutterIconDescriptor
    
    $gutter.Icon = "applicationsv2/32x32/add.png"
    $gutter.Tooltip = "Item doesn't have any version in " + $SitecoreContextItem.Language.Name + ". Click to create item version."   
 
    $gutter
}

Save this script as: /sitecore/system/Modules/PowerShell/Script Library/Sitecore Item Version/Sitecore Item Version/Content Editor/Gutters/Sitecore Item Version

Now rebuild Sitecore Gutter library using Sitecore PowerShell ISE.

Enable the Sitecore Item Version in Sitecore Gutter.

Change the language and you’ll see the add icon if item doesn’t have any version in the language you have selected.

Now let’s suppose you want to provide the flexibility to create the version on click of the gutter icon, we’ll write the Sitecore command, which will execute on click of the gutter icon and create an item version.

First let’s update the script for allowing the click on an icon.

Add the following line after $gutter.Tooltip

#Sitecore Gutter Click Event
    $gutter.Click = [String]::Format("item:createnewitemversion(id={0})", $SitecoreContextItem.ID)

Create Command Class with the following code:

public class Command : Sitecore.Shell.Framework.Commands.Command
    {
        public override void Execute(CommandContext context)
        {
            if (context.Items != null && context.Items.Length > 0)
            {
                Item contextItem = context.Items[0];
                if (contextItem != null)
                {
                    contextItem.Versions.AddVersion();
                    Context.ClientPage.SendMessage(this, string.Format("item:load(id={0})", (object)contextItem.ID));
                }
            }
        }
    }

When user click on the gutter icon we have to execute above piece of code which will create item version and open the item in the content editor. Wait, this won’t work directly, we have to add the command in the config file.

I’ve created a separate Class Library Project for this demo. You can refer GitHub:  https://github.com/nikkipunjabi/Sitecore-Item-Versioning

Create a config file and add the following code:

<?xml version="1.0"?>

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <commands>
      <command name="item:createnewitemversion" type="Sitecore.SharedSource.CreateItemCommand.Command,Sitecore.SharedSource.CreateItemCommand" />
    </commands>
  </sitecore>
</configuration>
Note: Do update the type appropriately as per the solution

Deploy the config and dll file in the webroot sitecore site.

Click on the icon and you’ll see an item version is created and it will get open in the content editor.

Happy Sitecoring!

Get Sitecore Workflow Items

In this post, you’ll see how to get Sitecore workflow items that are in the specific state of the workflow. I’ve described both the possible ways by which you can do it, Code and Sitecore PowerShell. 🙂

We need, workflow Id and workflow state Id.

var db = Factory.GetDatabase("master");
var workflow = db.WorkflowProvider.GetWorkflow(txtWorkflowID.Text);
var listofWorkflowItems = workflow.GetItems(txtWorkflowStateID.Text);

Above code, will get list of items in the given workflow state. I needed the report of these items along with the URLs. So I added the following code to get the required data. I are going to make use of this piece of code and bring in some more automation in further requirement. I’ll share more details in the upcoming posts.

Layout look as following:

<body>
    <form id="form1" runat="server">
        <h2>Get List of Workflow Items!</h2>
        <table>
            <tr>
                <td>Workflow ID:</td>
                <td>
                    <asp:TextBox ID="txtWorkflowID" runat="server" Width="400" Text="{115CBA9C-D124-49D5-B9D1-314B32155AAB}"></asp:TextBox></td>
            </tr>
            <tr>
                <td>Workflow State ID:</td>
                <td>
                    <asp:TextBox ID="txtWorkflowStateID" runat="server" Width="400" Text="{C8CB5D17-7F02-4A34-B2AE-36D1DB4A7089}"></asp:TextBox></td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblSummary" CssClass="positionAbsolute" Visible="false" Text="" runat="server"></asp:Label></td>
            </tr>
            <tr>
                <td>
                    <asp:Button ID="btnGetWorkflowItems" runat="server" Text="Get Items in Workflow" OnClick="btnGetItemsInWorkflow_Click" />

                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="lblCount" runat="server"></asp:Label></td>
            </tr>
            <tr>
                <td colspan="4">
                    <asp:GridView ID="grdLanguageReport" CssClass="table-style-three" runat="server"></asp:GridView>
                </td>
            </tr>
        </table>
    </form>
</body>

I created the DataTable and fed in the required data into it. Converted the path to URL if an item has any renderings.

Code:

        StringBuilder sb;
        DataTable tb;
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (Sitecore.Context.User.IsAuthenticated == false)
            {
                Response.Redirect("login.aspx?returnUrl=GetWorkflowItems.aspx");
            }
        }

        protected void btnGetItemsInWorkflow_Click(object sender, EventArgs e)
        {
            lblSummary.Text = "";
            try
            {
                if (!string.IsNullOrEmpty(txtWorkflowID.Text) && !string.IsNullOrEmpty(txtWorkflowStateID.Text))
                {
                    tb = new DataTable();
                    tb.Columns.Add("Item ID");
                    tb.Columns.Add("Item Path");
                    tb.Columns.Add("Item URL");

                    var db = Factory.GetDatabase("master");
                    if (db != null)
                    {
                        var workflow = db.WorkflowProvider.GetWorkflow(txtWorkflowID.Text);

                        var listofWorkflowItems = workflow.GetItems(txtWorkflowStateID.Text);
                        if (listofWorkflowItems == null || listofWorkflowItems.Count() == 0)
                        {
                            lblSummary.Text = "No Items found";
                            lblSummary.Visible = true;
                        }
                        else
                        {
                            List<string> listofItemsInTheWorkflow = new List<string>();

                            foreach (var ii in listofWorkflowItems)
                            {
                                var currentItem = db.GetItem(ii.ItemID);

                                DataRow itemRow = tb.NewRow();
                                itemRow["Item ID"] = ii.ItemID.ToString();

                                //For Item Path == Get Item ID
                                itemRow["Item Path"] = currentItem.Paths.FullPath;

                                //convert Item Path to URL
                                string getURLWithLanguage = "";
                                if (currentItem.Fields["__Renderings"] != null && currentItem.Fields["__Renderings"].ToString() != string.Empty)
                                {
                                    string urlWithLanguage = "https://www.companywebsite.com/" + ii.Language + "/";
                                    
                                    //Here you can do additional processing if needed
                                    
                                    getURLWithLanguage = currentItem.Paths.FullPath.Replace("/sitecore/content/Home/", urlWithLanguage);
                                    
                                }

                                itemRow["Item URL"] = getURLWithLanguage.ToLower();
                                tb.Rows.Add(itemRow);
                            }
                        }
                    }
                    lblCount.Text = "Total items: " + tb.Rows.Count.ToString();
                    grdLanguageReport.DataSource = tb;
                    grdLanguageReport.DataBind();
                }
            }
            catch (Exception ex)
            {
                lblSummary.Text = ex.StackTrace.ToString();
            }

There is an option to provide the Sitecore Workflow Id and State Id in the text box, and fetch the results based on it. You can add the feature to download the report into a sheet.

Another best way to get it done is using Sitecore PowerShell, if you have power to access on a required environment.

Provide the workflow state ID, find the referrence items using Get-ItemReferrer and then do the required processing. As simple as that.

$workflowStateID = Get-Item -Path master: -ID "{46DA5376-10DC-4B66-B464-AFDAA29DE84F}"
$referringItems = Get-ItemReferrer -Item $workflowStateID

#EmptyArray
$listofWorkflowItems = @()

#$listofWorkflowItems

#Skip System Items
Foreach($item in $referringItems) { 

    $itemPaths = $item.Paths.FullPath
    if($item.Paths.FullPath.contains('/sitecore/content/'))
    {
        $rendering = $item | Get-Rendering
        
        $addInList = New-Object System.Object
        $addInList | Add-Member -type NoteProperty -name ID -Value $item.ID
        $addInList | Add-Member -type NoteProperty -name Path -Value $item.FullPath
        if($rendering){
            $addInList | Add-Member -type NoteProperty -name URL -Value $item.FullPath.Replace("/sitecore/content/Home","https://www.nikkipunjabi.com")
        }
        
        $listofWorkflowItems += $addInList
    }
}

$listofWorkflowItems | Show-ListView

Output:

Hope this will help you as well if you are looking for any similar solution.

Happy Sitecoring!

 

Synchronize table data between SQL Server instances using SQL Table Dependency and NServiceBus

Data sync is the task which needs to be done very diligently. It should work effectively. In this post, you’ll see how we did data synchronization between the two SQL Server instances.

Challenge:

We had to capture the transaction in a few tables and move data to another database which is located on the other side of the world. There is no direct connection between the two databases. There is an integer primary key in the few tables. We had the flexibility to add a column but we couldn’t modify the existing columns because that is used by other applications.

Solution:

SQL Table Dependency – To monitor table change.

NServiceBus – A reliable data persistent storage where messages can be stored and that can be polled by the individual nodes.

We started with the SQL Table Dependency application which will track DB Changes. We followed the article Monitor Table Change with SQL Table Dependency. 

With this application, we were able to track Insert/Update/Delete changes in the table. It gives the notification message which has a complete record and we can play with it.

We were then suggested to use NServiceBus. It will persist the message until the message is read by the receiver. The advantage of using NServiceBus is it gives consistency guarantees till the message is read and processed by the receiver. The receiver will notify the Sender for the transaction processed successfully. You can start with NServiceBus Step by step to understand the architectural concept behind the software. The best about NServiceBus is it provides a lot of sample code which you can download and run the application to see how it works and understand. All the sample code should be working as you run the application. I personally tried with three sample codes.

We initially started with the Publisher-Subscriber application and used MSMQ for a data persistence. In this case, the sender and receiver both should run on the same server and can use the MSMQ to transfer the data. Because of some security norms, there wouldn’t be a direct connection between the source and target database. So we changed the approach and decided to go with NServiceBus Sender-Receiver application with NHibernate Persistence Usage. We did a POC keeping in mind the required business objectives, which worked very well and then we added the required business logic in SQLTableDependency, Sender, and Receiver to transfer the data from one server to another. It takes as little as 3-5 seconds for the data to be transferred and processed. The NServiceBus application has a mechanism to retry sending data if any issues, you can go through with the recoverability article to know more about it.

One SQLTableDependency application can track one table, we had to track other 5 tables as well. Data in the tables are associated with the Users table which the SQLTableDependency is monitoring. In SQLTableDependency, it’s not easy to monitor 5 tables in one application, there is some way but we didn’t invest time into that. We followed another approach. Users table is monitored by SQLTableDependecy, we added GUID column to track the record and push the same GUID on the target server tables. The operations on the Target Database is done based on the GUID.

We created triggers for 5 tables and one audit table to track the changes. In trigger we did two things, first, log the changes in the audit table and then update the user’s table which is monitored by SQLTableDependency with the GUID of the audit table. A business logic is in the SQLTableDependency to fetch the table changes using the Audit table and pass on the data to NServiceBus sender application.

I’m sure, you would have a question of how the application get notified about the data change?

We used MSMQ for storing the data from SQLTableDependency. NServiceBus sender will monitor the MSMQ. Any record added in MSMQ will be processed by the sender application and then removed from the MSMQ. NServiceBus NHibernate Sender-Receiver application uses SQL database internally for processing.  It creates a new database. Sender and Receiver both should have access to the database.

So we have three applications – SQL ServiceBroker (SQLTableDependency), Sender and Receiver. These applications will be running as a Windows Service and deployed on the servers. Receiver application will be running somewhere in the world and has access to Source and Target Databases using the secured VPN.

We created:

  • Triggers
    • Triggers for Insert, Update and Delete operations for the required tables. Triggers will add details about the transaction in the Audit Table and update the Users table with the SyncID.
  • Audit Table
    • SyncOperation table in SQL DB to track the changes in the above tables
  • SQL Service Broker with SQL Table Dependency application
    • This will track the users’ table.
    • On Insert/Update – It will take the values from the Users table and Sync Operation Table (if any) and push them to the Messaging Queue.
  • NServiceBus Sender
    • This will keep track on the MSMQ
    • Any data added in the MSMQ will be sent to the receiver and it will be cleared from MSMQ.
  • NServiceBus Receiver
    • A receiver will receive the data sent by the Sender.
    • It will then process the data by syncing it with the target Database.
    • Once the data is updated, a receiver will then notify the sender about the successful processing of the given data.
  • Stored Procedure
    • Stored procedure on the target database for each table to process the data

There are other ways as well to solve this business problem, We used this approach based on the requirement and suggestion from the client. Thanks to Senthilvel for helping me in this.

If you are going to use SQLTableDependency/NServiceBus and having any concern you can reach out to me.

Sitecore Federated Authentication – Part 3 – Sitecore User and Claims Identity

If you have followed my previous post, I hope you should now be able to login to Sitecore using External Identity Provider. In this post, we will see more about Claims Identity and store required values in Sitecore User Profile also we’ll create a user with the user’s email address instead of the hash code.

Claims Identity

Claims-based identity is a common way for applications to acquire the identity information they need about users inside their organization, in other organizations, and on the Internet.

Both Google and Facebook provide different claim identity name and value. So in order to bind properly, we have to update the configuration as below. You should explore Facebook Graph API from Facebook and OAuth 2.0 Playground from Google in order to get more information about the user.

In order to store the Full Name value of a user in Sitecore, I was trying to add http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name claim directly to a Full Name Property in Sitecore User Profile for a user in Property Initializer Mapping. But each time I try to add it always store sitecore\APTixbqulVz0qp5xEbNrkA in the Full Name instead storing Nikki Punjabi as a name, which I was getting from both the identity providers as a claim value.

Solution:

<!--Add Full Name Claim Transformation-->
<transformation name="name" type="Sitecore.Owin.Authentication.Services.DefaultTransformation,Sitecore.Owin.Authentication">
	<sources hint="raw:AddSource">
	        <claim name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" />
	</sources>
	<targets hint="raw:AddTarget">
	        <claim name="FullName" />
	</targets>
</transformation>

Read More