Creating Sitecore Items with a Specific ID with SPE

I recently needed to re-create an item that had been deleted by accident and was no longer available in the recycling bin or anywhere else. However this item needed to be created again with the same Id to avoid a lot of re-configuration.

I figured I might be able to do this with SPE (Sitecore Powershell Extensions) and after some digging it turns out there is a ForceId param supported by the ‘New Item‘ function that I hadn’t come across before.

It can be used like so – note: the -ForceId parameter that you will need to update to the Item Id you wish to use:

Once you’ve run this command you should see an item created with the Id you set as below:

add-item-with-new-id

 

 

 

 

 

 

 

I haven’t seen any other blog posts on this so hopefully it’s useful for anyone else who needs to do this in future.

Building Components in Sitecore 10 with the ASP.NET Rendering SDK

Last Thursday I presented at the London Sitecore User Group Online. This was the first online UK Sitecore user group this  year, which was a response to the Covid-19 Pandemic.

I Demo’ed how to Build ASP.Net Core Components in Sitecore 10 with the ASP.Net Rendering SDK.  The Demo uses a modified version of the Getting Started template to do this. An overview of the ASP.Net Rendering SDK is also provided and some useful Tips too.

Video Of Presentation

You can find a pre-recording of my presentation on my YouTube Channel here:

Steps To Build a Component in Sitecore 10

Bellow I’m going to detail the steps involved with Building a component in Sitecore 10 using the ASP.Net Rendering SDK. These are covered in the video but I thought it would be useful to write them down too and provide some further information where applicable.

Development Environment Setup

The first step is to get a Sitecore 10 Development environment setup. For my demo video above I used the getting started template. The Demo Video and this Overview starts from the point of having this installed. You could use docker and install everything yourself or install Sitecore 10 directly on your local development environment instead. However you would need to create your own Visual Studio project for the Rendering Host so this is more complex if you are just looking to experiment with this like I was.

Fellow MVP Robbert Hock has a really helpful video on getting the getting started template all setup and working so I’m not going to go into this further here: https://www.kayee.nl/2020/09/25/getting-started-with-sitecore-headless-development-asp-net-core-docker-containers/

note: to use the new ASP.Net Rendering Host SDK you will need to have access to the Layout Service within your Sitecore Licence, I believe currently this means you need JSS included in your licence.

I modified the Getting Started Template a little to include Bootstrap 4, some custom CSS and some new placeholders and components to make things a bit more interesting, but other than that my demo follows this fairly closely.

mandalorian

Building a Card Component

As covered in the demo we are going to build a Card Component (part of bootstrap) and follow a similar approach to the official documentation example for building a component. Assuming you’ve installed the getting started Template with the defaults the Sitecore CM instance will be visible here: https://cm.myproject.localhost/sitecore. If you wish you can add bootstrap 4 from here to the layout file in the Getting Started Template so that what you see will look more similar to the screen shot above. After completing all the steps below you could cerement your knowledge by adding an hero and some other components too (like I have above).

UPDATE (16/12/2020): 
I got asked if my version is available when I presented this at the Pittsburgh SUG Recently so I've uploaded it to Github here for those that want to replicate the look and feel of my demo or look at the code I used.

This version also uses Rich text for the Text field and and includes an image field: https://github.com/fluxdigital/Mandalorian.Sitecore.NetCore
mandalorian-netcore-demo

Create the Data Template

Create an data template called Card in the following location: /sitecore/templates/Project/MyProject. I called the data field section ‘Card Data’ but you can call it what you want.

Add the following 3 fields and set an icon:

  • Title  – Single Line Text Field
  • Text – Multiline Text Field
  • Link – General Link Field

template

Create the Json Rendering

Create a new rendering using the ‘Json Rendering’ template called Card in the following location: /sitecore/layout/Renderings/Project/MyProject/Card. Leave the Component name as ‘Card’.

rendering

Set the Datasource Location to: ./ ,set the template to the Card template you just created and set an icon:

rendering2

Create a New Placeholder

Create an new placeholder called myproject-container in the following location: /sitecore/layout/Placeholder Settings/Project/MyProject. Add the Card to the allowed controls.

placeholder

Add to Layout Service placeholders

The layout used by the Home item is as follow: sitecore/content/MyProject/Home. We need to Tell the layout service to return the placeholder.

Open the layout here: /sitecore/layout/Layouts/Project/MyProject/Main and add the myproject-container placeholder to the layout service placeholders field.

layoutservice

There is documentation on this here but it’s not 100% clear that this also applies to renderings: https://doc.sitecore.com/developers/100/developer-tools/en/layout-and-site-requirements-for-asp-net-core-rendering.html.

Add the Card Item in Sitecore

Add Card Item under the Home Item and populate the fields with some data.

demo-card

Add the Card to the Page

Open home item in Experience Editor and add the card to the placeholder and save the page.

exp

You will not see the card appear and will probably show an error message in place of the card at this point as we have yet to build the Component in Visual Studio and inform the Rendering Engine about our Component.

unknown

Publish the Site

Within the CM Smart Publish the Site.

publish

View Layout Service Debugging

Within the console you can Show the layout service response by typing the following command:

docker-compose logs -f rendering

docker

If you scroll down the logs you should see an empty response in the layout service for the myproject-container as we need to do some work in Visual Studio now to get this working.

Create the Model

Within Visual Studio Create a new Model called CardModel at the following location: rendering\Models with the following contents:

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using Sitecore.LayoutService.Client.Response.Model.Fields;
 namespace MyProject.Models
 {
   public class CardModel
   {
    public TextField Title { get; set; }
    public TextField Text { get; set; }
    public HyperLinkField Link { get; set; }
   }
 }

Note we are not using GlassMapper here we are using the new LayoutService Field Model. We use the TextField and HyperLinkFields for our Model.

Create the View

Create a new view called Card.cshtml within the following folder: rendering\Views\Shared\Components\SitecoreComponent\.

Add the following mark-up to include the 3 fields we created on our template earlier:

 @model MyProject.Models.CardModel
 <div class="card">
   <div class="card-body">
    <h2 class="card-title" asp-for="Title"></h2>
    <p class="card-text" asp-for="Text"></p>
    <sc-link asp-for="Link" class="btn btn-primary" editable="true"></sc-link>
  </div>
 </div>

Add Rendering Engine Binding

Within the Statup.cs file add the following line in bold to register the Card Model and Card View with the Rendering Engine.

// Register the Sitecore Rendering Engine services.
 services.AddSitecoreRenderingEngine(options =>
 {
 //Register your components here
 options
 .AddModelBoundView<CardModel>("Card")
 .AddDefaultPartialView("_ComponentNotFound");
 })

Add Placeholder to the Index Page

Update the index.cshtml layout file (rendering\Views\Default\Index.cshtml) to match the following. The main change here is to add the myproject-container placeholder:

 @model PageModel 
 @{
    ViewData["Title"] = Model.Title?.Value ?? string.Empty;
 }
 <main role="main">
    <sc-placeholder name="myproject-main"></sc-placeholder>
    <div class="container">
     <div class="row">
      <div class="col-md-8">
         <sc-placeholder name="myproject-container"></sc-placeholder>
      </div>
     </div>
   </div>
 </main>
 <nav class="navbar fixed-bottom navbar-expand-sm navbar-dark bg-dark" style="color: #fff;">
 &copy; @Model.CopyrightYear
 </nav>

Build the Project

Save and build the project to deploy the changes to the Rendering Host. As the Rendering Host is configured to use dotnet watch it should build and deploy the changes to the rendering host on save, so an build shouldn’t be needed really.

vs

View the page

Refresh the published page (by default: https://www.myproject.localhost/) to view the Updated home showing the new card component.

final-card

Your card may look a little different to this but it should be similar. Well done you’ve just built your first component in Sitecore 10 :-).

Tips

There are a few tips I picked up during my experimenting with this.

  • Check the Docker Console & Logs for errors if you are having problems:

    docker-compose logs -f rendering

  • If you have issues with Rendering Host or CM not updating then restart them both like so (docker can assign a new IP if you don’t restart both):

    docker-compose restart rendering cm

  • Read Up On Tag Helpers – https://doc.sitecore.com/developers/100/developer-tools/en/tag-helpers.html

Hopefully the video of my presentation and overview are useful for those who are considering using this new functionality in Sitecore 10 or are interested in knowing more about how this works.

Lastly thanks to Nick Wesselman for his help with some issues I had along the way and some diagrams for presentation.

My Sitecore Symposium 2020 Agenda

lonely-road-3

It’s Sitecore Symposium this week and It’s going to be a bit different this year. I attend Symposium in the USA most years and I’d usually be boarding a plane about now, this year (if it wasn’t for COVID-19) I’d be heading to Chicago. Instead the entire conference is Digital.

This means unfortunately I won’t get to catch-up with others in the Sitecore Community in person or get to do a bit of travelling which is a shame.
However there are some benefits though (other than it being a whole lot cheaper) which is that there a a lot of on-demand and breakout sessions which (if you purchase an all-access pass like I have) I believe you can access after the event. So unlike in the real-world you can catch up on sessions you’ve missed, in-light of this I’ve sometimes selected more than one clashing session.
An additional benefit I guess you’ll probably not have a hangover for those early Morning sessions either :-).

Anyway I’m looking forward to Sym and thought I’d share the sessions I’m playing on attending and why. You can find the full agenda here.

  Day 1 – Tue 27th


» 10:20 – 10:50am (CDT) – Sitecore business update with CEO Steve Tzikakis

Steve Tzikakis – Chief Executive Officer – Sitecore

– This is the first opportunity to listen to Sitecore’s now CEO. I’m looking forward to hearing what Steve has to say and his plans for the future.


» 11:45am – 12:45pm (CDT) – Influencer Roundtable with Microsoft: Integrating AI into your existing digital marketing strategy

Colin Wright – Director Strategy – Microsoft
Jonathan Weindel – Advanced Analytics Manager – Microsoft
Wina Wichienwidhtaya – MarTech Strategist – Microsoft Corporation

– I’m interested in seeing how other Sitecore customers are using AI and gaining further insights from Microsoft.


» 12:50 – 1:15pm (CDT) – Premium general session: The Road to Product Innovation

Desta Price – EVP Product Management – Sitecore
Tom De Ridder – Chief Technology Officer – Sitecore

– This is an all-access pass session and looks like it will give some insight into Sitecore’s plans for the future as well as the latest innovation’s in Sitecore 10. 


» 1:45 – 2:15pm (CDT) – Serialize your way to success

Charlie Turano – Product Manager – Sitecore

– I’ve installed Sitecore 10 and experimented with the new Seralization features but I’m looking forward to learning more about it.

OR

» 1:45 – 2:15pm (CDT) – 2020 and beyond: Integrating Sitecore with emerging technologies to wow your customers
Brian Henderson – Sitecore Architect – XCentium
Julia Gavrilova – Technical Director – XCentium

– Using Sitecore to power and Personalise 3D and AR technology sounds pretty cool to me so I’m intrigued to find out more.


» 2:20—2:50pm (CDT) – Real-time personalization in a true omnichannel world using JSS and Azure

Bas Lijten – Principal Architect – Achmea

– This sounds like an interesting approach and use of some of Sitecore’s newer features to fulfil some complex requirements.


» 3:10 – 3:40pm (CDT) – Containers & AKS: Taking Sitecore 10 to the next level

Bart Plasmeijer – Senior Software Architect – Sitecore
Rob Earlam – Technical Evangelist – Sitecore

– I’ve played around with the Docker examples for Sitecore 10 and have been impressed how quick and easy it is to spin up a development instance with Docker. I’m looking forward to hearing more and seeing how AKS can be used with Sitecore.

OR

» 3:10 – 3:40pm (CDT) – Content as a Service: A preview
Alistair Deneys – System Architect – Sitecore
Andy Cohen – System Architect – Sitecore

– I’m always keen to learn more about new Sitecore features so this session regarding Content as a Service (CaaS) should be interesting.

OR

» 3:10 – 3:40pm (CDT) – Insufficient facts always invite danger, Captain!
Neil Killen – Technical Director – Valtech

– Monitoring and performance of Containerized environments is all new to me so I’m looking forward to learning more about this.

  DAY 2 – Wed 28th


» 12:05 – 12:35pm (CDT) – Data privacy and Sitecore

Rob Habraken – CTO – We are you

– GDPR is tricky subject so I’m going to drop in on this session to make sure I understand all the touch-points to consider in Sitecore for the right to be forgotten.


» 12:40 – 1:10pm (CDT) – Sitecore AI: Auto Personalization Standard for Sitecore 10

Marcos Guimaraes – VP, Chief Data Scientist – Sitecore
Nancy Lee  – Principal Product Manager – Sitecore

– I’ve not really seen the Auto Personalisation in Sitecore 10 in action so I’m interested in learning more about this.

OR

» 12:40—1:10pm (CDT) – How to develop with the new ASP.NET Core rendering SDK
Nick Wesselman – PM, Developer Experience – Sitecore
Oleg Jytnik – Technical Lead – Sitecore

– I’ve been experimenting with the new ASP.NET Core rending SDK using the examples on https://doc.sitecore.com, but I’ve got a lot to learn still so I’m really looking forward to this session.

~ At this juncture I might do some yoga…no your right I probably won’t. I’ll likely just go and see if we’ve got any more biscuits in the cupboard instead. I’m just checking you’re still awake :-). ~

» 1.30 – 2.00PM (CDT) – Content Orchestration: A symphony between Content HUB and Sitecore XP using Content Hub Connector
Akshay Sura – Lead Platform Architect – Konabos Consulting
Sumith Damodaran – Sr. Product Manager – Sitecore

– Fellow MVP Akshay has been doing  a lot with Content Hub over the past few months so it will be great to learn more about Content Hub and Content Hub Connector.

OR

» 1:30—2:00pm (CDT) – Choosing the right option for building your Helix solutions
Shelley Benhoff – Lead Developer and Author – The Berndt Group

– Shelly has written some great Pluralsight courses so this session is bound to be informative.

» 2:45—3:45pm (CDT) – Failing Up: How to Take Risks, Aim Higher, and Never Stop Learning / Closing remarks with Paige
Leslie Odom Jr – Tony and Grammy Award-Winning Performer

Paige O’Neill – CMO – Sitecore

– The closing session of Symposium should be interesting and entertaining too.

On Demand

On top of all the live content there is a heap of On-Demand content too, I’m planning on watching some additional sessions on SOLR, SXA, Kubernetes, Content Hub, JSS, Upgrades and there are loads more for you to watch besides these.

It’s just as well I’ve taken 3 days off work to learn all of this. If you haven’t got a ticket yet then I think you can still grab one here. You’ll be missing out on a lot of interesting stuff if you don’t.

Creating Microsites In Sitecore without SXA

dynamic-sites-globe2

I’ve not used SXA in anger but have heard good things about it. Unfortunately due to licencing and timeframes it was not an option for me on a recent project where I was required to recommend and deliver an mechanism for quickly creating Microsites in Sitecore.

TLDR: If SXA is not an option then Dynamic Sites Manager might be a good alternative for you.

This meant I had 3 options:

1) Manual Configuration in the Sitecore Config
2) Use a Sitecore Microsite Module (such as the Multiple Sites Manager)
3) Write something custom to support adding Microsites dynamically

Manual Config wasn’t really an option as I knew that we had a number of Microsites to add and having a more flexible approach with less work and maintenance involved was important. I also didn’t want to write something custom as I knew this would be a time-sink involving solving problems other people have already had to with one of the Sitecore Modules available.

Dynamic Sites Manager To The Rescue

After a fair amount of research and experimentation I decided upon an lesser known Module called Dynamic Sites Manager built by Pete Navarra. As we are using Sitecore 8.2 I decided to use this specific version (1.9.1) from Github.
This happens to be the most recent release of the Module. It does work with Sitecore 9.0 too.

Pete has written one or two posts on the Dynamic Sites Manager but during the setup and of the module and configuration of the various sites I learned some useful tips I thought I’d share. On the project I’m currently working on we have two Sites that are live using the Dynamic Sites Module so far and both are functioning well.
Pete was also really helpful on Slack fielding all my questions so I wanted to return the favour and blog about it.

Reasons I chose Dynamic Sites Manager

  • It’s been written for performance, it uses the Site Provider Pattern and doesn’t just hook into the HttpBeginRequest pipeline (like the Multiple Sites Manager does) – this can cause caching issues
  • Microsites an be added and (most) configuration implemented purely within Sitecore
  • Each Microsite has a number of settings that mimic native Sitecore config for a Site
  • Content for the Microsites can be created wherever you wish
  • Roles can be configured for Microsite content as normal in Sitecore
  • Existing Layouts, Components and functionality already created in Sitecore can be used in Microsites
  • The module works with Sitecore 8.2, has been around for a few years and has had 8 releases so is quite mature.
  • I tested the module with Sitecore 9.0 today and it works so when we upgrade to 9.x It should continue to work correctly.
  • The code is open source on Github so we can fork it and change anything if we need to
  • It has been battle-tested on large sites with 100s of Microsites

Installing the Module

The first step is to download and install the Module. You can download it from the Market Place. The direct link for 1.9.1 is here.

Install the module using the package installation wizard as normal.

dynamic-sites-1.9-install-2

Once the module installation has completed open the DynamicSites.config.example config file  here: /App_Config/Includes/X.SharedSourceModules and rename  to DynamicSites.config.

dynamic-sites-1.9-install-3

 

 

 

 

 

This will enable the module and configure the default settings for the module, as defined at the top of the file this config file adds:

1) Event Handlers to Update Custom Chosen Templates with Dynamic Sites Base Template
2) Site Providers for both Dynamic Sites as well as a Switcher Provider.
3) Dyanamic Site Default Settings. All Dynamic Sites will inherit from these default properties.
4) 4 Sitecore Settings.

I’d recommend leaving this as it is for now and coming back to tweak settings if you need to.

Module Configuration

The next steps are to configure the module settings within Sitecore and create your first Dynamic Site.

You can set some general settings if you wish for the module here: /sitecore/System/Modules/Dynamic Sites/Dynamic Site Settings. You will probably find you can just leave most of the default settings here ‘as is’.

One thing you may want to consider doing is updating the Site Definition Template. The dropdown highlighted below allows you to set a custom template as the Site Definition template. This adds a Dynamic Site Definition Base template to the item and allows site configuration to occur on the item level:

dynamic-sites-1.9-install-4

This will likely be if you wish to customise the configuration settings in future.

For now you can just continue with using the Site Definition Template that ships out of the box with the Module.

Creating A Dynamic Site

For this example I’m going to do this on my local machine but if this was on another environment the process would be very similar. I have a site called ‘Demo Site 1’ which I’ll use for this example:

dynamic-sites-1.9-install-6

  1. Go to: /sitecore/system/Modules/Dynamic Sites/Sites
  2. Right click on the folder to Insert a new Dynamic Site Definition (I called mine ‘Demo Site 1’)
  3. Configure the Key Settings for your Site such as:
    – Hostname – the url which will be used for your Site
    Home Item – the Home item of your site (In my case: /sitecore/content/Demo Site 1)
    Port – this will be (I hope!) 443 for Live but locally you may be using Port 80 perhaps. If you using a self signed cert locally you can use 443 locally too.
    Database – this will likely be web for local testing (depending on if you want to view the published or un-published content)dynamic-sites-1.9-install-7

    Dynamic Site Custom Properties – you can over-ride any settings you wish that are usually on the <site> node in the Sitecore config here or you can add any custom properties you need to support. For example I had a custom cdn url property that I added which you can see below.dynamic-sites-1.9-install-8
  4. Add your binding in IIS to your Sitecore site, this is my local Sitecore 8.2 u7 instance:
    dynamic-sites-1.9-install-9
  5. Add a host file entry to the Site (on another environment this would obviously be handled with a DNS).
  6. Ensure your Website Homepage is in it’s final workflow step and Published. If all is well you should then see the webpage if you visit it in your browser (e.g: http://demosite1.local)

dynamic-sites-1.9-install-5

Supporting Preview / Published Sites

Our content editors wanted to be able to preview their content on the CM (Master) before publishing to CD (Web). I wasn’t sure on how best to handle this scenario so I reached out to Pete on Slack and he was really Helpful.

It turns out the best way to set this up is to create two Site Definition items, one for CM and one for CD. Both sites should have the Home Item set as the same (most other settings will be the same also).

The CM Site Definition item needs to be at the top of the list (above the CD Site Definition item – so it resolves first on the CM) and be set as un-publishable. Note I’ve pre-fixed my Site Definitions with CM and CD to easily identify them:

dynamic-sites-1.9-install-11

 

You then need to configure a different hostname for the CM Site (e.g: master.demosite1.local). If all is well you should be able to view the master site and see differences in the Master content:

dynamic-sites-1.9-install-12

Other Considerations

WFFM

One of the stumbling blocks I came across is that when configuring the default Web Forms For Marketeers form folder I got an error as it couldn’t find an ID. The issue was that I was including the brackets within the config in the Site Definition. Therefore ensure you remove the brackets like so:

dynamic-wffm

Unicorn

If you use Unicorn to sync your Sitecore items across environments. You may wish to sync your Dynamic sites and content via Uncorn. I settled on 2 different configurations to handle this.

A new items only configuration to deploy the Main Site Home Item only one like so (this is redacted):

<configuration name="Dynamic Sites New Items Only" description="Unicorn Config for new Dynamic sites items only (Existing items, deleted items or changed items are ignored)">
 <evaluator type="Unicorn.Evaluators.NewItemOnlyEvaluator, Unicorn" singleInstance="true"/>
 <dataProviderConfiguration enableTransparentSync="false" />
 <predicate>
 <include name="DynamicSitesNewItemsOnlyDemoSite1" database="master" path="/sitecore/content/Demo Site 1/Home">
 <exclude children="true"/>
 </include>
 </predicate>
 <dataProviderConfiguration enableTransparentSync="false" />
 <syncConfiguration updateLinkDatabase="true" updateSearchIndex="true" />
</configuration>

A main configuration to deploy component content folders and setting items to the site likes so (this is redacted):

<configuration name="DynamicSites" description="Unicorn Config for DynamicSites Items">
<predicate>
 <exclude path="/sitecore/content/Demo Site 1/Home" />
 <exclude childrenOfPath="/sitecore/content/Demo Site 1">
 <except name="Forms" includeChildren="false"/>
 <except name="Components" includeChildren="false"/>
 </exclude>
 <exclude childrenOfPath="/sitecore/content/Demo Site 1/Components/Banners" />
 <exclude childrenOfPath="/sitecore/content/Demo Site 1/Components/Promos" />
 <include name="DynamicSitesMediaFolders" database="master" path="/sitecore/media library/DynamicSites" includeChildren="true">
 <exclude childrenOfPath="/sitecore/media library/DynamicSites/Demo Site 1/Images"/>
 <exclude childrenOfPath="/sitecore/media library/DynamicSites/Demo Site 1/Files"/>
 </include>
</predicate>
<!--exclude the dynamic sites fields that will be different for each environment-->
<fieldFilter type="Rainbow.Filtering.ConfigurationFieldFilter, Rainbow">
 <exclude fieldID="{2E6EA147-39B4-48B9-B729-89DB73646518}" note="'Hostname'" key="Hostname" />
 <exclude fieldID="{671F0A96-8270-49C6-B25C-17A4A4EE5730}" note="'Port'" key="Port" />
 <exclude fieldID="{A9B6C54F-88CB-4A9F-9250-6B2B1D26B79C}" note="'Properties'" key="Properties" />
 <exclude fieldID="{E6869EFC-46EB-458E-9990-3DBF914E6F85}" note="'Database'" key="Database" />
</fieldFilter>
<dataProviderConfiguration enableTransparentSync="false" />
<syncConfiguration updateLinkDatabase="true" updateSearchIndex="true" />
</configuration>

Note the use fieldFilter usage here to exclude deployment of the environment specific fields such as the Hostname.

Caching

The caching for the Dynamic Sites module has been implemented using a custom Sitecore cache and therefore shows up in the Sitecore Cache.aspx page viewer. If you want to explore what is in the cache to debug any issues with Caching then you might want to use an tool to do so. I used this Cache Viewer SPE Module and it worked really well for seeing the cache for each Site. The cache key used is DynamicSites.SiteCache.

dynamic-cacheviewer

You should find that if you clear the cache then any settings you update should update and be reflected.

Default Context Database Issue

We had some issues serving some Dynamic Sites from the CD Server. The error we were seeing was:

ERROR An error while Initializing occurred
Exception: System.InvalidOperationException
Message: Could not find configuration node: databases/database[@id='master']
Source: Sitecore.Kernel
 at Sitecore.Configuration.DefaultFactory.GetConfigNode(String xpath, Boolean assert)
 at Sitecore.Configuration.DefaultFactory.CreateObject(String configPath, String[] parameters, Boolean assert)
 at Sitecore.Configuration.DefaultFactory.GetDatabase(String name, Boolean assert)
 at Sitecore.Configuration.DefaultFactory.GetDatabase(String name)
 at Sitecore.SharedSource.DynamicSites.Utilities.DynamicSiteSettings.get_GetCurrentDatabase()
 at Sitecore.SharedSource.DynamicSites.Utilities.DynamicSiteSettings.get_GetSettingsItem()
 at Sitecore.SharedSource.DynamicSites.Utilities.DynamicSiteSettings.get_SitesFolder()
 at Sitecore.SharedSource.DynamicSites.Utilities.DynamicSiteManager.GetDynamicSitesDictionary(Site defaultSite)
 at Sitecore.SharedSource.DynamicSites.Sites.DynamicSitesProvider.InitializeSites()
 at Sitecore.SharedSource.DynamicSites.Sites.DynamicSitesProvider.GetSites()

After some further digging into the DynamicSiteSettings class It turned out that for some reason the module was not finding the context database and so was falling back to Master in this block of code:

public static Database GetCurrentDatabase
 {
 get
 {
 return Context.ContentDatabase ?? Context.Database ?? Database.GetDatabase("master");
 }
 }

Our CD servers do not have access to the Master database so thats why the error only occurred on CD. To resolve this I branched the module and added a setting for the database fall-back instead of a hard coded ‘master’ value. This is set like so in the config:

<!-- Dynamic Sites - Fallback Current Database
 The database to fallback to when getting the current database 
 if Context.ContentDatabase & Context.Database are null
 -->
 <setting name="DynamicSites.FallbackCurrentDatabase" value="master" />

On our CD servers we set this to Pub where our published live content exists and this resolved the issue. This issue doesn’t seem to occur on an out of the box install of 8.2 u7 or 9.0 so It may be a nuance of our specific setup but if you come across if feel free to use my patched version.

Conclusion

We’ve only launched two Sites using the Dynamic Sites Manager Module so far but it’s working really well. Obviously you don’t get a bunch of pre-built components and some of the other Bells and Whistles you get with SXA but if you need  flexible, simple, well implemented, and full-featured Microsite/Dynamic Site solution which allows you to use your existing page templates and components then I can highly recommend it.

Thanks again to Pete for his hard work on this and his assistance. I’ll try not to ask him any more questions…

New UK Sitecore User Group Website

TLDR

If you are looking for Manchester Sitecore User Group or London Sitecore User Group events please visit: https://scug.co.uk/

Why we are no longer using Meetup.com

Meetup recently announced a change to their pricing policy for organising meetups and now want to charge each attendee $2 to RSVP for an event.

Given that it’s unlikely that everyone will want to pay this to RSVP to SUGs a New UK Sitecore User Group Website has been created by Steve McGill and Johannes Zijlstra. We are no longer using Meetup.com anymore to advertising UK SUGs.

The Manchester, London, Bristol and Cardiff Sitecore User Groups will all be using https://scug.co.uk/ to advertise SUGs going forwards.

Sitecore User Group UK

 

suguk-login

 

 

 

 

 

 

 

You can register for an event by clicking the Login link at the top of the page and login with either: Google, Facebook, GitHub, Microsoft, Twitter or LinkedIn.

You can do so safely, we will not share your email address with anyone, including sponsors.

As the Site is fairly new I thought I’d write this post to try and raise awareness of it and encourage people to Signup for the upcoming London and Manchester Sitecore User Group events.

Upcoming Sitecore User Groups

The following is a list of up-coming UK Sitecore User Groups:

> London Sitecore User Group

26th February 2020 @Avanade, 30 Cannon Street

https://scug.co.uk/events/2020/02/london-avanade-sitecore-usergroup/

> Manchester Sitecore User Group

11th of March 2020 @Valtech’s Offices, Basil Chambers, 65 High Street, M4 1FS

https://scug.co.uk/events/2020/03/manchester-sitecore-usergroup/

Hopefully this is useful for those not aware of this change and we’l see you at one of the UK SUGs soon.

Thanks to Steve and Johannes for their time to building and updating the Site too!. I’m trying to help with some new features and if you fancy helping out too then. I’m sure they would be happy for your to input.

Installing Sitecore 9.3 And Horizon

TLDR

Installing Sitecore Horizon involves first installing Sitecore 9.3 and then Installing Horizon as a separate module from here. Follow the Sitecore Horizon install instructions below.

Sitecore 9.3 dropped yesterday and It ships with a number of updates to JSS, SXA, Sitecore MVC and Sitecore Forms and more. However the Mostly Highly anticipated part of this release is Horizon – Sitecore’s all new Page Editing interface (yes ‘Page Editor’ is back – but this time built with Node and much faster). Horizon also has Simulator Mode and Insights View which look pretty cool.

horrizon-editing

For those of you keen to take a look at Horizon in more detail this blog post is going to give you an overview of how to install Sitecore 9.3 and Install Sitecore Horizon on a local development environment.

Sitecore 9.3 Install

In 9.2 Sitecore released a new simple installer called SIA (Sitecore Installer Assistant) and that is what we are going to use to install Sitecore 9.3. You can also install Sitecore via SIF and ARM Templates but were going for the quickest and simplest option in this post.

SIA will also install all of the elements now required to run an Sitecore instance for you such as Solr, Identity Server and xConnect. It doesn’t however install Horizon for you so we’l also cover that later on in this post.

Step 1 – Download The Installer

You want the ‘Graphical setup package for XP Single’ package from this page:
https://dev.sitecore.net/Downloads/Sitecore_Experience_Platform/93/Sitecore_Experience_Platform_93_Initial_Release.aspx.

Download the zip file, unblock it and extract it.

Step 2 – SIA Pre-Requisites

To use SIA (or install Sitecore 9.3 in any way) you will need to have the following in place:

  • IIS 10
  • .NET Framework 4.7.2
  • .NET Core 2.1.12 Windows Hosting Module
  • SQL Server 2016 SP2 and 2017
  • Microsoft PowerShell® version 5.1 or later
  • An Valid Sitecore Licence for 9.3

Step 3 – SIA Install Process

Run the Setup.exe file from the extracted folder and click ‘Start’.

sia-start

There are a number of great blog posts out there that cover using SIA in detail – such as Robbert Hocks excellent guide, so I’m not going to go through all the installer steps in detail, However I will summarise them here and provide some tips.

  1. Pre-requisites – SIA uses SIF under the hood and requires version 2.2 of SIF.
    It will try and install it for you but If you have issues with the installer failing at this step you may wish to check which version(s) of SIF you currently have installed:

    Get-InstalledModule -Name SitecoreInstallFramework -AllVersions

    You might need to uninstall old versions before trying SIA again. More info on this here: https://www.koenheye.be/multiple-versions-of-the-sitecore-install-framework/

  2. Install Solr – Solr is now required as part of the install. If you already have an instance of Solr running on port 8983 then choose a different port for your 9.3 install. I would suggest something like ‘sc93-‘ as the prefix as SIA installs Solr 8.1.1 for you and when it creates the windows service and folder it appends ‘solr-8.1.1’ to the prefix you enter like so: ‘sc93-solr-8.1.1’.
  3. Sitecore Settings – SIA will append ‘sc.dev.local’ to whatever you add as the instance prefix so ’93’ would make sense here. It will also use this prefix to name the XConnect and Identity Server sites too:93-sites

 

 

I bet most people will still us ‘admin/b’ as the username and password too :-).

sc-9.3-install-complete

Once you’ve completed the other steps in the installer it will validate the install and should complete the installation in around 10-15 minutes. If you have any issues then check the logs in SIA. If all went well you should be able to open your site by clicking the button on the final SIA screen or going to it in your browser, e.g: https://93sc.dev.local/.

Sitecore Horizon Install

You may have noticed during the install that SXA was an optional module you could install from SIA, unfortunately Horizon isn’t, hopefully it will be in future releases. Therefore we need to install Horizon separately. I hit a few stumbling blocks with the install which I’ll cover at the end.

Step 1 – Download The Install Files

You want the ‘Sitecore Horizon for On Premises deployment’ package from this page: https://dev.sitecore.net/Downloads/Sitecore_Horizon/93/Sitecore_Horizon_93_Initial_version.aspx

Download the zip file, unblock it and extract it.

Step 2 – Sitecore Horizon Install Pre-Requisites

Before you begin the install ensure you have the following in place:

  • You’ve installed Sitecore with HTTPS, SIF 2.2.0 & Sitecore Identity is installed (you will have done if you’ve used SIA ‘as is’)
  • Web socket protocol is installed, you can enable this under ‘turn windows features on and off’.
    web-socket-protocol

 

 

 

 

 

More info here: https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/iis-80-websocket-protocol-support

dotnet --info

dot-net-runtime

  • You have Node 10 and npm 6 installed. If you don’t have Node installed at all then use this download package for Windows: https://nodejs.org/dist/v10.0.0/node-v10.0.0-x86.msi.
    I prefer to use NVM myself to install and manage node versions but I could not get Horizon to start for some reason despite having node registered correctly on my Path variable in Windows.
  • Your Sitecore licence must also include Horizon or you won’t be able to run it.

Step 3 – Sitecore Horizon Install Process

Open up the parameters.ps1 file from the extracted folder and set values for the following parameters:

  • $ContentManagementInstanceName – this should be the name of the Sitecore instance you just created in IIS via SIA – e.g “93sc.dev.local”.
  • $ContentManagementWebProtocol – this should always be “https”
  • $SitecoreIdentityServerPhysicalPath – this should  be the path to the Sitecore Identify instance you just created in IIS via SIA – e.g: “C:\inetpub\wwwroot\93identityserver.dev.local”
  • $SitecoreIdentityServerPoolName – this should be the name of the Sitecore Identify instance app pool  – e.g: “93identityserver.dev.local”
  • $SitecoreIdentityServerSiteName – this should be the name of the Sitecore Identify instance – e.g: “93identityserver.dev.local”
  • $LicensePath – this should be the path to where your licence file can be found – e.g: “C:\inetpub\wwwroot\93sc.dev.local\App_Data\license.xml” – This one is important to get right to avoid some of the errors I hit with the license ending up in the wrong folder (see Troubleshooting section), the official installation PDF isn’t clear about this but it is the FULL PATH including the FILENAME.
  • $authoringHostName – this will be the url that Horizon will run on, the install file tries to set this for you based on the name of your Sitecore instance etc but you can set this if you wish, I set this to: “horizon.93sc.dev.local”. – Others have mentioned to me that when they didn’t set this they had issues. Also make sure you name the Host Name using the same domain as the Sitecore Content Management instance, so that the format is like so: {something}.{cmsinstancename} as above.  as in the official install PDF Guide it mentions a change regarding how cookies work in Chrome which will break this if you don’t follow this format.

params

 

 

 

 

 

 

 

 

 

Now open up the Install.ps1 file and run it (make sure you are running it as an Administrator).

horizon-install1

 

 

 

 

 

 

 

 

 

 

 

 

Wait a few minutes and the install process should complete:

horizon-install2

 

 

 

 

 

 

 

 

 

 

 

 

Once it has completed you can either go to your horizon instance in your browser, e.g “horizon.93sc.dev.local” or you can re-start and open up your Sitecore 9.3 instance and click on the swanky new Horizon Icon that you should see on your Launchpad:

horizon-icon

 

 

 

 

 

All being well Horizon should load and you should see the following screen:

horrizon-complete

Sitecore Horizon Install Troubleshooting

One of the main reasons I wrote this guide is I had a few issues with the install. I’m going to outline them below and the fixes required.

Debugging Horizon

First some tips on Debugging Horizon as I couldn’t find much out there on this.

    • Run the Authoring.Host.dll directly from the root folder (e.g: C:\inetpub\wwwroot\horizon.93sc.dev.local) like so to give you direct output on the errors in the console:

dotnet Authoring.Host.dll

run-host

    • Check the logs in your Horizon app (e.g: C:\inetpub\wwwroot\horizon.93sc.dev.local). By default I think they just write to the root folder. You will see two different logs: ‘AuthoringHost’ and ‘stdout’ logs. If you are not seeing any logs then edit the web.config file at the root of the Horizon app and check stdoutLogEnabled is true, you can also change the path for the log files here.

stdoutLogEnabled=”true” stdoutLogFile=”C:\inetpub\wwwroot\horizon.93sc.dev.local\logs\stdout” />

Errors & Issues

Here are some issues I had which I had to resolve.

HTTP Error 502 – Process Failure

This error basically just means that dotnet core could not run the app. It’s a pretty generic error message which can mean a number of things so you need to dig into the logs to find out more info.

horizon-error

I didn’t have an issue with my .net versions but one key thing to check first is that you have the right versions of the .net core runtime installed.

Licence Error

Looking in the logs for more info this is the first error I was getting:

Unhandled Exception: System.InvalidOperationException: License file doesn’t exist on disk.
at Sitecore.Framework.Runtime.Commands.SitecoreHostCommand.LoadLicenseXml(String filePath, String contentRootPath)
at Sitecore.Framework.Runtime.Commands.SitecoreHostCommand.OnExecuteAsync(CommandLineApplication app)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.InvokeAsync(MethodInfo method, Object instance, Object[] arguments) in C:\projects\commandlineutils\src\CommandLineUtils\Conventions\ExecuteMethodConvention.cs:line 77

To resolve this I needed to copy the licence folder into the /sitecoreruntime folder e.g: c:\inetpub\wwwroot\horizonsc93sc.dev.local\sitecoreruntime.
I’m not sure if this is a bug but the installer seemed to put the licence file in the wrong location (/config).
Thanks to Vlad for his help with this: https://sitecore.stackexchange.com/questions/23209/running-horizon-failed-http-error-502-5-process-failure.

Patch File Error

This was the 2nd error I was seeing:

Unhandled Exception: Sitecore.Framework.Configuration.Patcher.ConfigurationException: An error occurred during applying the patch file: C:\inetpub\wwwroot\horizon.93sc.dev.local\Config\license.xml —> System.Exception: Could not merge node ‘signedlicense’ in patch file ‘license.xml’
at Sitecore.Framework.Configuration.Patcher.XmlPatcher.ShouldPatchNode(XmlNode target, IXmlElement patch)
at Sitecore.Framework.Configuration.Patcher.XmlPatcher.Merge(XmlNode target, IXmlElement patch)
at Sitecore.Framework.Configuration.Patcher.XmlPatcher.ApplyPatch(String filename, XmlNode node)
at Sitecore.Framework.Configuration.Patcher.ConfigReader.LoadIncludeFiles(IEnumerable`1 files, XmlNode node)

To resolve this error I had to remove the licence that was not needed from /config (e.g: C:\inetpub\wwwroot\horizon.93sc.dev.local\Config ) as this was confusing Horizon.

Failed to render a page

I was seeing this error. This means that Horizon is running now but there is an failure in rendering the application.

horizon-load-error

NodeJs Error

Looking in the logs for more info this is the 3rd error I was seeing:

System.InvalidOperationException: Failed to start Node process. To resolve this:.

[1] Ensure that Node.js is installed and can be found in one of the PATH directories.
Current PATH enviroment variable is: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Gpg4win\..\GnuPG\bin;C:\Program Files\azcopy;C:\Program Files\Git\cmd;C:\Program Files (x86)\dotnet\;C:\Users\Adam Seabridge\AppData\Roaming\nvm;C:\Program Files\nodejs;…
Make sure the Node executable is in one of those directories, or update your PATH.

I had this issue for two reasons:

1) I was trying to use NVM to manage my node versions and it would not find my node version even though node was registered correctly on my path. I couldn’t resolve this so ended up installing Node using the Windows installer instead of NVM.
2) I needed to restart IIS after I’d installed node. I would recommend a reboot of your machine after you install Node.

 

That all folks. Hopefully others who are keen to see Horizon in action will find this useful.
Feel free to comment or tweet me with any suggestions on any of the installation process or things I’ve missed.

You can find the docs on Horizon here. Enjoy.

Accelerating Development of Sitecore Components with SPE

I’ve recently been creating a lot of new pages and component for the latest designs for the client I’m working with and and after creating a bunch of components I thought there must be an quicker and easier way to do this.

TLDR: Use Sitecore Powershell Extensions to automate the process of creating Components in Sitecore

Lets looks at some of the steps you commonly go through as a Sitecore Developer when creating components:

  1. Create the Component Data Template
  2. Pick an icon (we all know this takes the longest amount of time :-))
  3. Create an Component Folder template item for the Components to be organised in
  4. Add Standard values and Insert options on the Folder template for the Component and Component folder
  5. Create test content organised into folders using the Component and Component Folder templates you’ve just created
  6. Create a View Rendering
  7. Add the View Path, Data Template and Data Source Location and cache settings to the rendering

angtft

Pretty monotonous right? So with SPE I figured I could automate most of this process, I managed to do most of it and save a whole bunch of time. Often your Component Templates and Renderings are created in the same location in Sitecore and with a standard naming convention so this ins’t too difficult.

The Functions

First up I created 3 of functions to simplify each part of the process.

Scaffold Component & Folder

Creates Component and Folder templates at the specified location and standard values and set insert options for standard values on the folder.

Create Component Datasource

Create component datasource based on component base path and template path and names.

Scaffold View Rendering

Creates a View Rendering at the specified location and adds View Path, Datasource location, Data template and cache settings.

Calling The Functions

You can then call the functions like so – using the example of creating an Hero:

Import-Function Scaffold-Component-And-Folder

Scaffold-Component-And-Folder “Hero” “/sitecore/templates/Shared/Components”

components

Make sure you set the component template path to where your components are created for your Site. This should create you an component and folder for your component with the insert options set etc.

Now just pick an decent icon for your component and folder, add your fields and your done.

 

Import-Function Create-Component-Datasource
$componentName = “Hero”;

Create-Component-Datasource -ComponentBasePath “/sitecore/content/Global Content” -TemplateBasePath “/sitecore/templates/shared/components” `
-ComponentFolderName “$($componentName)s” -ComponentName “$($componentName)” `
-ComponentFolderTemplateName “$($componentName) Folder” -ComponentTemplateName “$($componentName)”

Make sure you set the component and template base path correctly for your project and the names for the templates to use. You could modify this function to create multiple test content items if you wish also.

Import-Function Scaffold-View-Rendering
$renderingName = “Hero”;

Scaffold-View-Rendering -RenderingName $renderingName -RenderingPath “/sitecore/layout/Renderings/Shared” `
-ViewPath “/Views/Shared/$($renderingName.Replace(” “,”-“)).cshtml” `
-DataSourcePath “/sitecore/content/Global Content/$($renderingName)s” `
-DataSourceTemplate “/sitecore/templates/$($renderingName)”

Make sure you set the rendering and view path to where your views are created for your Site in Sitecore and your Project. Also ensure the Datasource Path and Template are set correctly. This should create you your view and configure it for you. Now just pick an decent icon and your done.

Once you’ve got these 3 functions and script to call them setup it’s surprisingly quick to create new components in Sitecore, allowing you to focus on the important and more complex stuff. I’ve accelerated my development quite a bit since I created these and cut down on mistakes/missed configuration.

Hopefully you will find them useful too.

I’ve gone further than this by publishing the templates, renderings, content, images etc with SPE for local testing and a few other things to speed up development but thats a post for another day.

I demo’ed some of this at the Leeds Sitecore User Group Meetup Last week also:

As usual there were are few posts out there that were really useful for creating these scripts such as the following:
https://stackoverflow.com/questions/38193871/sitecore-create-new-template-item-using-spe
https://sitecore.stackexchange.com/questions/15171/is-it-possible-to-edit-the-insertitems-of-an-item

The Business Case & Considerations for a Sitecore 9.2 Upgrade

smoke-2551073_1920
I don’t often write Sitecore blog posts from a business perspective but I today I thought I would as I think some Sitecore customers are still on 8.x or 9.0 and are considering an upgrade to Sitecore 9.2.

With Sitecore 9.3 likely to be released later this year and mainstream support for 8.2 and below running out in December now is a good time to consider upgrading.

In this post I’m going to outline what the benefits of moving to 9.2 are and also the considerations you should make before embarking on an upgrade.

What are Benefits / Features of Sitecore 9.2?

This is usually one of the first questions that will be asked. I’m not going to keep this fairly high-level as there are many in-depth blog posts out there on Sitecore 9.1 & 9.2 features but the following should provide a succinct summary.

Sitecore 9.1 & 9.2 bring a lot of new features and there has been a big focus on splitting features and functionality out from the previous large monolithic architecture to a smaller modern micro-service based architecture:

  • Sitecore Cortex – Sitecore’s new Machine Learning Brain which can Suggested Personalisation and process and leverage customer data
  • Sitecore Identity – Single Sign On and Federated Authentication (using IdentityServer)
  • Sitecore Universal Tracker – Provides an central Analytics API to track  interactions from any device (e.g mobile apps, IoT, AR and VR)
  • Sitecore JavaScript Services (JSS) – allows development of apps using front-end frameworks such as Angular, React and Vue, using Sitecore as the source for the data (including SXA & Sitecore Forms support in 9.2).
  • Sitecore Accelerator Framework (SXA) Accessibility Improvements – SXA has been around for a couple of years and is a package or pre-built components for Sitecore allowing you to get sites up and running quicker.
  • Sitecore Host – A lean common runtime for .NET Core applications (Powers: Horizon, Universal Tracker, Sitecore Identity)
  • Helix Configuration – 9.1 shipped with some Helix configuration already setup. Helix is Sitecore’s recommended approach to building Sitecore Sites it sets out an number of overall design principles and conventions to follow.
  • Sitecore Installer Assistant (SIA) – 9.2 provides a new GUI for easily installing Sitecore in a few clicks
  • SSL offloading – 9.2 provides an SSL offloading config to Improve security and performance by shifting SSL Processing onto separate processors
  • Active Personalization Dashboard – 9.2 has a new new dashboard which provides an overview of all personalization actively occurring, providing visibility of poorly/well performing tactics to act upon.
  • Many other improvements including: Search, Content Delivery, xDB and Analytics, Sitecore Forms, EXM, SIF(2), YAML Item Serialization, Bug Fixes and performance Improvements

But We’re on Sitecore 8.2 or below, what else do I get?

Mainstream Support

If you are yet to upgrade to Sitecore 9 then you need to consider this soon as Mainstream support for 8.2 and below expires in December 2019. https://kb.sitecore.net/articles/641167
This means that whilst Sitecore will still provide security updates and fixes and endeavour to assist with product incidents they may not provide support for the following:

  • Assistance with errors or unexpected behaviour during installation or development
  • Addressing product defects as hot-fixes or patches
  • Compatibility fixes for supported technology platforms.

Therefore if you are on 8.2 or below after December this year then you may need to upgrade to resolve certain issues (depending on what the issues are).

Sitecore 9.0 Features

If you are on 8.2 or below you will also benefit from all the features released in 9.0, here are the key ones:

  • xConnect – Provides an unified API that centralises data access
  • Headless CMS support and JSS – Allows web apps to be built with React, Angular, Vue using Sitecore data
  • Rules based configuration – Configuration is now much simpler as it can be set based on the server role (e.g Content Delivery, Content Authoring)
  • Sitecore Install Framework (SIF) – SIF is a framework for installing Sitecore using automated scripts. This is how Sitecore 9 and above is now installed and it means deployments can be automated easier.
  • Sitecore Accelerator Framework (SXA) – SXA is a pre-built set of components to allow pages to be developed quicker with less development effort
  • Sitecore Forms – Sitecore 9.0 has newly designed forms to replace WFFM. These are built in a modern way and are easier to configure and customise.

Upgrade Considerations

sitecore-logo
So there are clearly some significant benefits to carrying out an upgrade to Sitecore 9.2, especially if you are on 8.2 still, as some customers are.
There are some additional requirements and considerations when moving to Sitecore 9.2 and standard upgrade considerations which need to be planned for:

  • Additional Servers / Roles – Due to changes to the architecture to split out elements of Sitecore into smaller services Sitecore 9, 9.1 and 9.2 require some additional Servers and roles. These are for xConnect, Identity Server, Cortex and processing. When you are planning resources for your upgrade this should be considered, particularly on Azure as there are quite a few additional services required.
  • Module Upgrades – Most Sitecore sites will make use of a number of Modules to extend the out of the box functionality. Some popular modules are: Web Forms for Marketers (WFFM), Url Rewrite and Sitecore Powershell Extensions (SPE). It is important to ensure that each module you are using is supported in Sitecore 9.2 and to consider time for upgrading each module as part of the upgrade process.
  • Updated Licence – Most customers will require a new licence generating when upgrading to Sitecore 9 and above. Therefore ensure you request this from your account manager in advance and that you have all features/modules you require included on your licence.
  • Active Directory module – Sitecore 9.1 & 9.2 or later does not support the Active Directory module. Sitecore uses Identity server to handle logins instead of legacy methods such as AD. Therefore if you are upgrading to 9.1 or above and use the AD module you will need to implement an integration with Active Directory from Identity Server.
  • Search – Sitecore 9 and above no longer supports Lucene so you must use SOLR or Azure Search. Lucene did not work well in distributed search scenarios so moving to SOLR or Azure Search has been recommended for a while. SSL is also required for SOLR in 9.0.
  • Code & Configuration Updates – Sitecore try and reduce breaking changes where possible but sometimes they are unavoidable, so as with all Sitecore upgrades some custom code and configuration will need to be updated to be compatible with Sitecore 9.2.
    To assist with this process Sitecore does provide an Express Migration Tool (to get to 9.0) and an Update Installation Wizard to update to 9.2. However these tools will likely only get you so far for highly customised Sitecore implementations and will likely need some manual upgrading too. Any code that needs upgrading will not be auto-upgraded by the tool. If you are on 8.2 then there are quite a few changes for analytics with xConnect. All references in Visual Studio will need updating to 9.2 also.
  • Support Patches & Hotfixes – You will likely have some hotfixes or support patches that have been applied to your solution over time. These will need analysing as part of the upgrade to understand if they are still required or not in 9.2. Many of these may have been rolled into 9.2 already.
  • Analytics Data upgrade – Part of the upgrade process involves migrating xDB data in the 8.x format to Sitecore 9.2 format. Sitecore have a tool for this: https://dev.sitecore.net/Downloads/Sitecore_xDB_Data_Migration_Tool/3x/xDB_Data_Migration_Tool_300.aspx
  • Implementation Quality – Best practice Sitecore implementations do not customise any out of the box Sitecore files and instead use patch files and extensions to customise configuration and other Sitecore functionality. Ideally the base platform should be installed ‘as is’ and the customisations layered on top to assist with upgradability. Depending on how well your implementation has been carried out will impact how easy it is to upgrade. If your implementation is not best practice then your team should take the time during the upgrade to correct this and take advantage of some of the newer and better ways of doing this.

A Note on Upgrading WFFM

sitecore-formsOften one of the key stumbling blocks for upgrading Sitecore to 9.1 or 9.2 is Web Forms For Marketers, this is because it was deprecated in Sitecore 9.1 and is also not supported in Sitecore 9.2. Sitecore 9.0.2 is the last release where WFFM can be used. Sitecore Forms has replaced it.  If customers have many forms this can be a bit daunting.

So you could just upgrade to Sitecore 9.0.2 and stop there, but you would be missing out on a lot of features and you will need to upgrade again in the near future. Thankfully there is another option, there is now a community built tool to help automate this for you and convert WFFM forms and data to Sitecore Experience Forms: https://github.com/afaniuolo/WFFM-Conversion-Tool. I have yet to use this but have heard good things about it and it is regularly updated.

 

I’ve tried to cover the key features of 9.2 and considerations for upgrading here. As you can probably see the longer you leave an upgrade the more complex it becomes as there are more changes to consider. Frequent upgrades of Sitecore should be the aim as this will reduce the time and investment needed to carry them out. Hopefully you’ll find this post useful for planning an upgrade to Sitecore 9.2 and leverage the investment you have made in the platform.

Excluding Specific Fields from Unicorn Serialisation (Field Filter)

unicorn

This week I had a situation where I needed to include some Sitecore Items in Unicorns Sync but exclude certain fields from those items.  In my case these were navigation items which had a link on them. I wanted to maintain the ids of the navigation item across environments but not the link – as it changes per environment.

I’ve used Unicorn a lot in quite a few Sitecore projects but I’ve never had to do this before so I wasn’t sure if it was possible or not.

It turns out it is, Unicorn has an feature called a ‘Field Filter’.

I can’t work out exactly when this became available but it looks like since version 4.0 Unicorn supports config based filtering.

Luckily we are on Unicorn 4.0.8 so we didn’t need to upgrade.

How do you use it?

Field filters are actually used in the <defaults> node in the Unicorn.config that is provided by default by Unicorn, here is an example of the Last run field being excluded:

<fieldFilter type=”Rainbow.Filtering.ConfigurationFieldFilter, Rainbow” singleInstance=”true”>
<exclude fieldID=”{B1E16562-F3F9-4DDD-84CA-6E099950ECC0}” note=”‘Last run’ field on Schedule template (used to register tasks)” />
</fieldFilter>

Adding the fieldFilter for a specific Configuration

Anything in Unicorn defaults can be overridden/defined at a configuration level  in my case this is what I wanted to do, here is how my custom configuration looks after adding in the exclusion rule for the Home Link field on my Navigation items:

After deploying this update and running Reserialize on this config I could see that the Home Link field had been excluded in the YAML file written to disk :-).

I couldn’t find much on this so thought this might help others who need to do this in future.

Further Options in Unicorn 4.1 – Field Transforms

After posting this Mark Cassidy (who works on Unicorn) tweeted me to remind me about a feature that has just been released and he blogged about it last week:

marks-tweet  

Essentially allowing you to keep certain fields under Source Control, but giving you much more control over what happens to the field values in specific environments using filters.

I haven’t tested this but it looks like this could be used like so to exclude my Home Link field:

In this case I’ve chosen to put the fieldTransforms on the <include> node but if you wanted to apply the filter to the whole config by adding it to the <predicate> instead.

When we’ve upgraded Unicorn to 4.1 I’ll test this and see how it works out.

 

Creating Multiple Uniquely Named Solr Instances For Sitecore Development

solr-red Since the release of Sitecore 9.x and above Solr has been the default Search service and there is an requirement to install Solr with an SSL Certificate in order to use SIF to install Sitecore.
To simplify this I’ve been using this Powershell Script that Jeremy Davis kindly created for a while now.

In general it works brilliantly but if you want to keep all your Solr instances in C:\Solr as soon as I try to install a 2nd or 3rd instance of the same version of Solr (e.g a 2nd solr-6.6.2 instance for 9.02) I run into issues.
The script assumes that you don’t already have a folder called “\solr-6.6.2” in C:\Solr and fails. It will also fail on a number of other steps such as the cert name, service name and zip download/extraction.

Therefore I’ve modified the Script to support passing in a suffix which creates a unique instance of Solr using a $solrSuffix variable for various steps in the script.

Just set this variable to something that makes sense for that instance of Solr and run it e.g:

$solrSuffix = 902dev;

You should then have an unique instance of Solr and you can keep running the script again and again as long as the $solrSuffix is unique and you update the values of  $solrPort and $solrHost each time also.

unique-solr solr-installed

 

 

 

The script below is setup for Sitecore 9.1 installs (using Solr 7.2.1), but if you change the $solrVersion to 6.6.2 and set the other 3 variables mentioned above you can use it for Sitecore 9.0.x installs too.

This updated script has saved me quite a bit of time over the past few months, hopefully others will find this useful too.
Thanks again to Jeremy for writing the original script.