This post is part of the What’s new in Sitecore 9.1 series, Sitecore 9.1 has a lot of exciting innovation and value that will help our customers get to market faster, and ongoing refinements and enhancements to existing functionality.
In previous posted we focused on the What’s new in Sitecore 9.1 Content Management. In this post we will look at all the marketing innovations, features and enhancements within the Experience Platform. Before we dive in I want to provide context around Sitecore, this will help to understand the unique opportunity we have with Sitecore.
Starting with some history, as we all know Sitecore originally was a Content Management System. Being well known of the central hub for serving all the managed and integrated content. Over the years Sitecore evolved from web and to additional channels; including email, mobile and any other marketing channel.
The main driver was the introduction the Online Marketing Suite back in 2009. One of the first Experience Marketing solutions in the industry. Now Sitecore is a full Experience Marketing platform and the Sitecore Experience Cloud allows customers to personalize both online and offline experiences while capturing all the data; including all interactions, conversions, test results, patterns and basically any user information online and offline.
Now the great thing about Sitecore is that it’s all one native platform, both CMS and the Experience Platforms are closely tight together, it’s a truly unified platform.
Sitecore’s unified platform is one of the reasons why Sitecore is loved by developers and marketers.
The true power of Sitecore is in combining the analytics data with the content. The platform provides you with the opportunity to create relevant personalized experiences in real-time.
During Sitecore Symposium I presented the Overview of 9.1 together with Mark Groves, Senior Director Product Management. This blogpost will cover the highlights of Sitecore 9.1 Experience Management (XM).
As addressed in the first blogpost of the What’s new in Sitecore 9.1 series, Sitecore 9.1 has a lot of exciting innovation and value that will help our customers get to market faster, and ongoing refinements and enhancements to existing functionality.
The most important headlines for Sitecore 9.1 Content management are; Headless, Sitecore Experience Accelerator (SxA), platform enhancements and the new UI – Horizon.
I just returned home from a great Sitecore Symposium and an MVP summit. I had the honors to present the Overview of 9.1 together with Mark Groves, Senior Director Product Management. During the days that followed I received a lot of requests to share the deck and the details. To address these questions I started a blog series on our 9.1 release.
So, version 9.1 has a lot of exciting innovation and value that will help our customers get to market faster, and also ongoing refinements and enhancements to existing functionality.
The Sitecore Hackathon is an community event organized by Akshay Sura and supported by Sitecore Technical Marketing. The results of the Hackathon 2018 where amazing; 220 participants, from 25 countries, divided into 74 teams, competed over 24 hours to build the most creative Sitecore module that demonstrates their competency in one of four categories: Commerce, SXA, JSS, or xConnect. The results will be announced and celebrated at the Sitecore User Group Conference (SUGCON) in Berlin.
After the announcement of the winners we had a very nice chat with Mark Styles and During the Sitecore User Group Conference 2018 in Berlin I had a very nice chat with Mark Styles and Jean-François L’Heureux (from now on called JF) one of the winners of the Hackathon.
As you probably know by now, the release of Sitecore 8.2 update 1 included full Sitecore Azure Web Apps support. I, along with the entire Sitecore community, am very excited about this release.
Exactly, this is because forms are a crucial part of every website. For most interactions forms is the starting point. This is how sites create business value for customers, this is how you generate leads and drive conversions.
When talking to business users (people that actually work with Sitecore on a day to day base) I created a small list of minor custom changes that would help the business users with there day to day work.
One of the items on this list is the condition for User Profile fields, by default the input of this field is a manual typed String. Which is a painful process for the business user They are not sure of the fieldname and go to the usermanager to verify the name. And even when they know the fieldname they surely can make a typo. After all even a business user is just human.
So after a small thought I started coding. My solution for this problem is simple. Create a custom Macro with a tree selection and return the item name! Let’s do this!
Create the custom Macro class
Open VS, and create a class called UserProfileFieldMacro that inherits from the IRuleMacro class.
Override the Execute method, in this method we need to define the custom Macro. Please read the code comments for explanation.
The UserProfileFieldMacro class has the following code
public class UserProfileFieldMacro : IRuleMacro
{
public UserProfileFieldMacro() { }
public void Execute(XElement element, string name, UrlString parameters, string value)
{
Database coreDatabase = Sitecore.Configuration.Factory.GetDatabase("core");
//Define default path to profile template
string profilePath = "/sitecore/templates/System/Security/User";
//Check if custom path is set in Macro parameters
if (parameters.HasPath)
profilePath = parameters.Path;
Item userProfileRootItem = coreDatabase.GetItem(profilePath);
//The path isn't correct, we want to log this error and send the user to the system administrator
if (userProfileRootItem == null)
{
string error = string.Format("The path ({0}) set in the user profile field condition doesn't exist", profilePath);
Sitecore.Diagnostics.Log.Error(error, this);
SheerResponse.ShowError(error + " Please contact your system administrator", string.Empty);
return;
}
SelectItemOptions options = new SelectItemOptions();
//Set and hide the root of the tree in the dialog window
options.Root = userProfileRootItem;
options.ShowRoot = false;
//User can only select Templatefields
options.IncludeTemplatesForSelection = new List { TemplateManager.GetTemplate(TemplateIDs.TemplateField, coreDatabase) };
//Return the item name to the public property
options.ResultType = SelectItemOptions.DialogResultType.Name;
//Set dialog window info
options.Title = "Select User profile field";
options.Text = "Select the user profile field to use in this rule.";
options.Icon = "applications/32x32/media_stop.png";
//Trigger the dialog window
SheerResponse.ShowModalDialog(options.ToUrlString().ToString(), true);
}
}
Compile your code.
Create the Items in Sitecore
Login to Sitecore and open the content editor.
Create the macro item
Go to the /sitecore/system/Settings/Rules/Common/Macros folder and create a new Macro item called UserProfileFieldMacro. Set the Type field to match your custom Macro class and assembly.
Create the condition item
Go to the /sitecore/system/Settings/Rules/Common/Conditions/Security folder and duplicate the User Profile Condition Item, name the duplicated itemUser Profile Field Selection Condition.
Now we need to change the Text field so it will use the custom create Macro instead of the default string input. Go to the Text field, I highlighted the part that we are changing
where user profile [FieldName,,,specific] field [operatorid,StringOperator,,compares to] [Value,,,value]
What you see is a four column seperated string. The four columns are representing the following functionatily:
the public property in the condition that will be set.
the macro used to get the user input (blank is string input)
optional parameters to pass to the macro
the text value that appears to the business user when the value is not set
Now change this to use the custom created Macro
where user profile [FieldName,ProfileFieldOperator,,specific] field [operatorid,StringOperator,,compares to] [Value,,,value]
If you look at the Macro code you will see that if no parameters are passed we use the path to the default user profile. If you have custom user profile you can pass the path as a parameter. For example;
where user profile [FieldName,ProfileFieldOperator,/sitecore/templates/System/Security/Jetstream User,select] field [operatorid,StringOperator,,compares to] [Value,,,value]
Now where all set to test the new condition!
Activate and test the condition
Open the page editor and select a presentation component you want to personalize. Click the personalize button and create a new rule.
Select the for the where user profile select field compares tovalue condition and click the red select link. The custom Macro will now fire the dialog window where all the profile fields are available for selection.
And the best thing is if the business user selects a Field section the a message will appear. No more humon errors here 🙂
So for my example I configured the following rule for a component called Summer sun.
Test the conditional rendering rule
If I visit the website as a logged-in user with the firsts name Pieter the Summer sun component will appear. Otherwise the component will be hidden.
Let’s visit the website as a anonymous visitor.
Now after I login with my account (and yes my first name is Pieter) the control will appear.
Wrap up!
This solution is specifically created for user profile fields, you could also create a more generic Macro with more custom parameters. For me the most important part is that I showed you how easy it is to create a custom Macro. The next time the business user confront you with their problems, don’t just tell them this is the way Sitecore works. Tell them that you can easily change the behavior of Sitecore within a few hours. And of course share your customizations with us!