Changing Sitecore Item Data Templates with SPE

spe icon This week I needed to change a number of navigation items from an old navigation item data template to a new one. I didn’t want to have to do this by hand as I have quite a few items to update, so I decided that Sitecore Powershell Extensions (SPE) was the quickest and easiest way to do this. If you don’t know about SPE I’ve written more about it here.

There isn’t an function as such to do this in SPE so I put one together and thought I’d share it here.

How do I use it?

The function updates the data template of an item (and optionally it’s child items) from one template to another. It has 4 parameters:

  • RootItemId – Specifies an Item Id to start searching for items from
  • SourceTemplateId – Specifies the Id of the template to match items on (the template you wish to change)
  • TargetTemplateId – Specifies the Id of the template to change items to
  • Recurse – Specifies if all the child items below RootItemId should be included in the search.

An Example

Change-Template -RootItemId 36584658-7B62-4572-932E-8214A3CD7CE8 -SourceTemplateId 92C1C171-3ED0-4E8F-860A-FEAF14336A96 -TargetTemplateId DD68EBBB-4D82-411C-BA19-D95A65AAEF83 –Recurse $true

Change-Template Function

Hopefully this is useful for others who need to do something similar.

Potential Improvements / Alternatives

If you have an number of templates that you want to update in various locations in your Sitecore solution you could use the Get-ItemReferrer option before the | Where-Object query and this will get all items referencing the template instead of searching the entire Sitecore content tree. In my case however I didn’t want to update all items with old template, just ones under a specific path.

I could perhaps update my function at some point to accept a $UseGetItemReferer boolean option and also allow for a null $RootItemId in order to support this and make the function more flexible.

Sitecore Symposium 2018 – Thoughts and Takeaways

I’ve just arrived back from Symposium 2018 in Orlando, Florida and thought I would share some of what I learnt with those who couldn’t make it this year.

5274I’ve been to a previous Symposium in New Orleans but as I missed it last year due to moving house I was keen to attend again this year. This time around it is also my first as an MVP and is a great opportunity to learn more about the latest release of Sitecore and what’s planned for the future.
I would be joining over 3000 attendees with 3 days of sessions on all things Sitecore. I arrived early evening for registration the day before and caught up with a couple of Sitecorians. The conference would start proper the following day.

Day 1

Opening Keynote

5899
This year Symposium kicked off with an opening keynote by Paige O’Neill & Mark Frost. The theme this year is ‘elevate the experience’ and  there were some welcome announcements from Sitecore:
  • JSS finally in general release – I’ve experimented with JSS and seen it go through quite a few changes and improvements over the 4 technical previews but it wasn’t officially supported. With the 9.1 release it will be generally available and officially supported. This is great to see and there were many talks on JSS throughout Symposium that made my want to try and get using it on future projects where possible.
  • Stylelabs acquired by Sitecore – Stylelabs has been acquired by Sitecore to provide true DAM capabilities for assets in Sitecore. The integration isn’t there yet but it’s certainly an interesting announcement and from demonstrations of the products abilities it looks like it could add some real benefits and powerful asset management features to Sitecore.
  • Sitecore Cortex TM – Cortex is part of the new Micro services architecture that is present in 9.1. It is Sitecore’s Machine Learning brain which provides Content tagging, automated personalization recommendations (with preview). It also supports flexible integration with 3rd party systems and other Machine Learning engines and platforms. Again there were quite a few sessions on this at Sym, more on this later.
  • Deeper Salesforce Integration – with 9.1 it is now possible to see behavioural data integrated into Sitecore.
5906
Following this keynote there were Talks by:
Volvo – who showed off their Car as a service offering (CaaS) where customers can swap their car every 12 months or in future even for a weekend trip with the family. An interesting concept that could be the future of Car usage.
Cannondale – who used IoT devices to pass data to the Website about customers bike usage which then used Machine learning to recommend bikes for them based on how they ride and check stock based on their location. They had also built augmented reality into their app to assist customers with setup and maintenance of their Bike. Pretty cool stuff.
Sickkids – this is a charity that raises money for Kids who are not well. They used to have fairly average charity branding but re-branded from a needy charity to create strong engagement with potential donors. The videos that were shown were very hard-hitting and I think there were are few people in the room that got a bit emotional :-). They have so far raised $628 million in 6 months and are halfway to raising over 1 billion dollars which will be the most ever raised by a charity in a year. During the event Sitecore donated $25 for every 3 minutes ridden on a bike for Sickkids (which I and about half of the attendees did) which raised $50,000 for Sickkids.
5913
NotImpossible – Last and not least Mick Ebeling from NotImpossible talked about how his company have created tech for the greater good to help: create special glasses to allow an artist he was introduced to not only speak again but to draw art with his eyes. Create a wristband that uses vibrations to allow deaf people to feel music and which also was ‘potentially’ a cure for Parkinson’s. And lastly how he setup a 3D printing lab in Africa to print a boy who lost his arms two new arms and then taught the locals how to use the machines to print arms for $100 which would usually cost $15,000!. This guy was truly inspirational and a brilliant story teller. He also came up with the best phrase of the conference:
‘Commit. Then figure it out’
Hopefully more companies will take inspiration from this and look to do more to help others, as Mick said it’s good for shareholder value and good for the world.
After this is what time to have lunch and head to our first break-out sessions, I decided to start with a Session on Headless.

Headless CMS and the Great Uncoupling – Deane Barker

5922
This talk was interesting and made a number of points about the current state of the headless CMS vendor market and where the likes of Contentful sit compared to Sitecore. The key takeaways from this were:
  • Contentful and others Headless CMS’s are currently not the same as Sitecore, they only offer part of the picture – content repository, they don’t offer preview, drag and drop etc.
  • The market has turned from a blue market where they were disruptive and new to a red one where it has matured and it is now more crowded.
  • Headless vendors are selling to IT again now instead of Marketing. However Marketing will start to ask how they view, personalise or track things with a headless CMS and therefore vendors will start to add these features. Some have already tried to add things like preview and a basic page editor.
  • Sitecore already has all of this functionality built in so is strongly positioned to cater for this change

The Cortex Engine, process at scale – Alistair Deneys

5929
I went to find out more about Cortex and got a deep-dive into the inner-workings of Cortex. The key takeaways here were:
  • Cortex provides intelligence and moves us into a contextual era of content management
  • Has a task based system which decides how to run a task depending on it’s type and allows tasks to be chained
  • It can pull from many different sources, including external systems
  • Uses an ML Model and uses the same Message Bus as xConnect
  • Can Sync content to other systems for analysis

Sitecore 9.1 Overview – Pieter Brinkman

6141
This talk crossed over with the Cortex talk so I couldn’t attend it. However I did install 9.1 recently and have seen other info on it at Symposium. I’ll be writing a detailed blog post on this soon but here are a few Sitecore 9.1 pointers:
  • Helix Folder Structure is provided by default
  • Significant speed improvements have been made (as much as 20 secs for CE)
  • Personalisation & Platform enhancements
  • Sitecore Identity Server comes with 9.1 – Single Sign On / Federated Authentication
  • Cortex – Suggested Personalisation
  • JSS now in General Release
  • Universal Tracker – Mobile Analytics
  • Horizon – New UI

Horizon uncovering core UX and architectural concepts – Alec Orlov

5950

This session was on the new Sitecore content and page editing User interface that is in development and will be released after 9.1, probably in an update.

  • It will co-exist with the existing Content Editor and Experience Editor interfaces.
  • It will be a new launchpad icon for now but will eventually replace Content Editor and Experience Editor
  • It is brand new and build using the new Microservices based architecture in Sitecore 9.1 to make it a lot faster
  • It supports existing MVC field renderer code for Experience Editor
  • Horizon does not yet support JSS

5952

5964

This was really good to see and a welcome improvement on the current Sitecore UX. It will be interesting to see how this affects existing Content Editor and Experience Editor customisations and what effort is required to re-implement these.

Working with JSS Gold Master and Marketing Automation – Rick Bauer & Corey Smith 

5978
Corey and Richard presented on their experiences of using the final release of JSS:
  • They talked about the different modes: connected, disconnected, headless etc
  • How quick it is compared to MVC development and that MVC developers need to start learning React/Vue/Angular to avoid the risk of becoming obsolete
  •  Showed how analytics are still tracked and how you can still protect against things like cross site scripting attacks

Closing Keynote – Daymond John

5984
Daymond John from the US TV show Shark Tank closed out the first day with his story of how he created FUBU clothing, got hip hop artists to wear it and turned it from a bedroom business into a multi-million pound selling product. It was an entertaining and amusing talk and served as a good end to an informative day.

Day 2

Helix and JavaScript Services (JSS) – Jean-Francois L’Heureux

5989
  • It makes sense to keep the same structure for front-end code as back-end code by splitting front-end code into feature folders and components and using similar naming conventions.
  • Use custom linters (eslint) to validate that the front-end development approach follows Helix principles by enforcing certain rules within the linter.
  • Jeff has added JSS app templates to github which you can use to start projects off with a Helix architecture.

You can see more info on this here: https://www.jflh.ca/2018-10-13-helix-and-sitecore-javascript-services

Integrated DevOps with Azure, Git, PowerShell and Slack – Rob Habraken

5999
Rob showed us the build pipeline he uses on some projects, integration with various tools and processes he follows:
  • Devs are worried about deployment, they shouldn’t be if they release little and often.
  • Unicorn used to push out database updates and and Razl to sync back locally
  • 20% of time on a sprint is spent on DevOps tasks and 1hr per sprint is spent on fixing SonorCube issues
  • PRs should be mandatory and all releases created from the trunk. Labels in Github can be used to manage this.
  • Connect Slack to Github to see releases and PRs and also use custom Webhooks to allow for custom Slack commands to see which build was live currently etc.
  • Content should also be part of Continuous Delivery
  • CD should be warmed up after deployment but it is not possible with CMs

You can find out more info here: https://www.robhabraken.nl/index.php/3000/integrated-devops/

Leveraging Sitecore data on a static website with GatsbyJS and GraphQL – Bryan Mills and Adam Lamarre

6061

This was an interesting talk about using the JSS GraphQL engine in Sitecore with Gatsby to build websites.

  • The final product is just static HTML in a flat file
  • Demo’d a site built with Gatsby
  • Results in: simple deployments, no boilder-plate or back-end code, direct field access
  • Good for: Microsites, Product Sites, Time-limited Sites, Sites for lead-generation, Dashboards, Knowledge Base
  • Is  used by some big brands such as Nike, Airbnb, Facebook

You can see the demo here: https://github.com/millsb/symp-gatsby

Day 3

10x your Sitecore development – Mark Cassidy

6144

Mark gave us some of the benefit of his 13+ years of Sitecore development with some tips and tricks on how to reduce complexity and development time for Sitecore sites:

  • Mark Demo’d building a Sitecore 9 Site from scratch with no frameworks, mappers, Code generators, ORMs
  • As Sitecore developers we should be looking to reduce complexity of Sitecore builds. End-clients of Sitecore often complain about the complexity of Sitecore solutions.
  •  Divide the work horizontally, not vertically to allow less experienced developers to contribute and more experienced devs to focus on the more complex work.
  • Sitecore APIs can be used directly without abstractions – KISS.
  • 1 to 1 – 1 Controller, View, Model, Datasource etc per component

you can find Marks presentation, Site used and video here: https://github.com/cassidydotdk/Sym2018

A Helix approach to devops in light of the Sitecore micro-service architecture – Thomas Eldblom

6156

Thomas created the idea of Helix and in this talk explained how Helix principles can be applied to infrastructure too:

  • Sitecore is getting more complex and therefor the Infrastructure layer should now be considered below the foundation layer as part of the Helix architecture
    6159
  • The infrastructure layer should define: Resources, Platform, Storage/Networking Services, App Roles, Extensions & Packages
  • Sitecore as a service doesn’t exist right now but this is what customers want and it’s up to us to help customers achieve this

Closing Keynote: A look into the future – Ryan Donovan

6199

In the closing keynote we were shown a demo of how Stylelabs will integrate with Sitecore to manage assets and a recap on the key takeaways from Symposium.

And with that it was the end of another great Symposium, I’ve learn’t a lot over the past week or so and I’ve got lots of ideas to think about. It was also great to catch-up with fellow Sitecore MVPs and make some new friends, I’m already looking forward to Symposium next year.

Ryan Bailey

Before I go I should mention that sadly a fellow MVP Ryan Bailey Passed away shortly before Symposium.  Although I didn’t know Ryan I heard some amazing things about him at Symposium and have been helped by some of the posts he regularly wrote on his blog: https://blog.ryanbailey.co.nz/.

A site was created to help raise money to support his family and Incredibly due to community the site has raised over 13k so far: https://givealittle.co.nz/cause/support-for-ryans-family

You can donate at the above link and read more about this here:
https://sitecorestorm.blogspot.com/2018/10/an-amazing-thing-happened-at-sitecore.html.
Props to Corey and Kam who helped get more donations by shaving off their Stache and Beards at the MVP Summit!

Sitecore Update Package Timeout Issues

It’s been a little while since my last blog post as my Baby Daughter Char(Charlotte-Sienna) arrived 2 months ago which has made it a bit challenging to find time to write some. This seems to have happened to a bunch of Sitecore developers I know and it’s took me a while to get back to it.

I don’t have a Sitecore T-Shirt for her yet so given the lack of pictures in this blog post here’s one of her in an England shirt from back at the World Cup. It didn’t help, we still lost…

 

Update Package Woes

I recently had to upgrade a local Sitecore 8.2 update 6 instance to 8.2 update 7 using the Sitecore Update Installation Wizard and ran across a timeout issue which was as follows:

‘Sitecore.Shell.Upgrades.PostStep,Sitecore.Client’
Error executing post step (Sitecore.Shell.Upgrades.Bug118164PostStep): System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. —> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) …

There was more to the error but you get the idea. It looked like an issue with SQL Timeouts. I wasn’t sure why as on my local machine (with a local database) connections should be pretty quick.


TL;DR

Close all other programs / browser tabs to free up RAM & Processing power, make some config changes and add the patch file at the bottom of this post to Sitecore (Temporarily – delete it afterwards) to avoid the timeout issues during update package installation.


upgrade-log

I tried a few more times, waited a while, tried again and still no joy. A bit of Googling and I cam across a few posts related to update package install issues, this one on SSE being the best:

https://sitecore.stackexchange.com/questions/2772/problems-while-installing-an-update-package

There was lots of useful info here, some of it seemed to help, some of it didn’t.

Interestingly a number of people reported having this issue on other environments where connections might have more latency such as UAT or Production.

How I fixed it

I tried doing just a few of the things mentioned in this SSE post (and others I found) but in the end I needed to do all of the following to get the 8.2 update 7 update package to finish installing:

I thought it would be useful to share this so others can quickly move past these errors without wasting lots of time like I did.

Also I’ve not tried this in Sitecore 9 but I’d imagine most of these steps will still help (some updates will likely be needed to the config patch file for role based config).

Steps to resolve the issue

    1. executionTimeout – Edit the web.config and change the following setting for executionTimeout to set it to 18000:

      <httpRuntime targetFramework=”4.6.1″ maxRequestLength=”512000″ executionTimeout=”18000″ enableKernelOutputCache=”false” relaxedUrlToFileSystemMapping=”false” requestValidationMode=”4.0″ enableVersionHeader=”false” />

    2. Ping Maximum Response Time – In IIS, go to the app pool used by Sitecore and either change the ‘Ping Maximum Response Time (seconds)’ to 600 seconds or other larger value or set ‘Ping Enabled’ to false.
    3. Clear Down Previous Upgrade Files & Logs – Remove/Archive any folders here: \temp\__Upgrade. It’s also worth clearing down your Sitecore logs to make it easier to debug.
    4. Config Patch – Apply the config patch file below (add any additional indexes to disable)
    5. Try Again – Re-start the installation of the Update and package. Hopefully it succeeds this time!
    6. Undo Config Updates – Roll back the updates made in steps 1,2 and 4.

Config Patch

The following config patch should be copied into your /App_Config/Include folder. Please add any other custom indexes that you need to disable or make changes if you have renamed any.

Also Please ensure you delete this patch file after you have completed the update.

Some useful links:

https://sitecore.stackexchange.com/questions/2772/problems-while-installing-an-update-package

https://sitecorebasics.wordpress.com/2014/06/21/sitecore-version-upgrade-troubleshooting-basics

https://sitecorebasics.wordpress.com/2012/02/26/browser-timeout-error-while-doing-sitecore-version-upgrade

https://kiranpatils.wordpress.com/2012/02/26/long-running-processes-and-browser-timeout-issue-mainly-internet-explorer

Anyways I hope this is helpful for others who have this issue.

An Sitecore Multilist field with an External Datasource

This week I needed to create an Multilist which required a DataSource that doesn’t reside in Sitecore.
I’ve done this a few times before but using an DataSource for a Multilist from outside of Sitecore isn’t something I have needed to do often.
There aren’t many articles on how to do this, so I thought I’d write up how to do this using Sitecore 9 (it should work with Sitecore 8 and below too).

hqdefault

I’ve based the implementation on the code from this post by Benjamin Vangansewinkel: http://sitecoreblog.blogspot.co.uk/2012/04/how-to-create-custom-multilist-field.html. So Kudos to Benjamin for writing this back in 2012. The are alternatives to this approach such as using creating a custom token or a custom data provider but I feel a custom Multilist is simpler and easier to manage.

Benjamin’s post is really useful, but some of the code is missing and I needed to show a count of the items available and selected in my Multilist. I’ve also simplified things a little bit and included the full code with an example API call to populate the list.

When it’s complete it will look like this:

multilist-external

Ok lets get started.

Create a Base Class – BaseExternalMultiList.cs

So that we can re-use this implementation for other Multilists with external DataSources we are going to create a Base Class that encapsulates the code for building the Multilist.

The class provides the method for rendering out the Multilist field and I have updated the Javascript to show a count of the number of available items and the selected items when you add or remove items from the list.

Create An Custom MultiList Field – CryptoMultilist.cs

The next Step is to Create our Multilist field by implementing the Base Class. There are 3 methods here that can be implimented:

  1. InitRendering() – in this method we will call our API and populate the list.
  2. GetNonSelectedItems() – in this method we will get our list of all available items.
  3. GetSelectedItems() – in this method we will populate our list of selected items.

Just for fun I’m using an example of a Multilist field that lists all available Crypto Currencies. I’m using this API to get the list: https://www.cryptocompare.com/api  

The API Service – CryptoService.cs

You can obviously use any Service but this example makes a simple call to get a list of Crypto Coins. There are a lot of them apparently, 2528 at time of writing!. This is not production-ready code but provides a simple example for testing. Replace this service with any other service you like to return a list of items.

Supporting Classes

There are some supporting model classes required by the above Service code that allow me to Serialize the JSON response from the API to these models. I’m using Json.Net to do this.  Depending on the API you are using you will need to update these models as required.

Once you have added the above code to your project you can then move on to configuring Sitecore to use your custom Multilist field.

Adding the Custom Multilist to Sitecore

Go to the Core database in Content Editor and navigate to:

/sitecore/system/Field types

Create a new item called ‘Crypto Multilist’ using this template:

/sitecore/templates/System/Templates/Template field type

It is best practice to create a new folder to hold your custom field types (if you don’t have one already).

Add the Assembly and Class information (based on the namespace and assembly of the files you have added). Add an icon to identify your field easier also.

core-db-multilist

 

Save your new field and then go back to the Master Database in Content editor and navigate to a template you wish to use the new Multilist field on.

Using your Multilist Field

You should now be able to add your new Multilist field to any Data template by selecting it as a Field Type from the dropdown.

add-field-template

Now when you add or edit an item using this Data Template your Multilist field should display populated with the External data and maintain the selected items when saving and going back to the item.

new-field-on-item

Thats all there is to it, you can now re-use this approach for any additional External Datasources you wish without much effort by switching out the service and models.

I might package this up and put it on NuGet at some point if it’s useful. I’d be interested to know of easier or better ways of doing this also.

 

Sitecore SUGCON 2018

Estrel
I’ve just come back from SUGCON 2018 in Berlin and I think it was the best one I’ve been to yet. It was my third time attending the Sitecore User Group Conference (a conference for the Sitecore Community organised by the Sitecore Community). This year I was lucky enough to be going as a first-time MVP and would be collecting my award during the conference.

I arrived early to see a bit of Berlin on the Sunday and catch up with some friends, colleagues and other Sitecore Devs and MVPs and before I knew it it was time for SUGCON to start.

sky

It kicked off with some fancy lights and music and Peter Brinkman with the opening Keynote explaining how large SUGCON has grown since it started in 2016, there were 600 attendees this year!.

There was a lot to take in over the 1.5 days so before I forget it all I’ve summarized below some key learning’s from my two days at SUGCON 2018.

Day 1

Opening Keynote – Pieter Brinkman

welcome

    • There will be two major Sitecore releases every 6 months and (spring & fall) which will contain new features and functionality
    • Updates / Patch releases will only contain fixes and not features/breaking changes.
    • Releases will be a full delivery including code, training and documentation

Sitecore releases

Great news for all Sitecore developers and customers who have been frustrated with this in the past.

Commerce + IoT In Powerful Ways – Jason Wilkerson & Richard Seal

Next up was well known MVPs Jason Wikerson and Richard Seal who created a fictional SitecoreLand complete with wristbands to access the park to demonstrate how IoT can be used with Sitecore .

IoT

    • Previously this was only possible by building most of the functionality yourself buy it is now possible out of the box with xConnect + and IoT Hub and IoT Listener.

IoT

  • Store the least amount of data you need to achieve what you want to do for your customers.
  • With SXA, Experience Commerce, xConnect, EXM, xDB and Marketing automation you now have all the tools you need to create these kind of experiences for customers with Sitecore. Your imagination is the only limitation.

Impressive stuff and a real show-case for what’s possible with Sitecore. Speaking to Jason afterwards he said it took longer to Photoshop in the memes of Longtime MVP Jeremy Davis who got trolled hard in the talk. This wasn’t to be the only time today either :-).

Jeremy

Uber-modern Apis For Sitecore – Kam Figy

Kam has been building the CLI for JSS and underlying APIs and took us through some of these focusing heavily on GraphQL.

graph API explorer

  • GraphQL is:
    • Strongly Typed
    • Queries only the specific fields you need (no overfetching)
    • The response matches the query (so you know what you are getting)
    • Is discover-able
    • Batches queries and catches and returns errors
  • Kam demo’ed an app he’d built that used GraphQL and mimic’s the database browser in Sitecore.

jss browser

  • It’s possible to extend the GraphQL API using Query Extenders and add additional fields. These are than patched in using config.

extender

links

All-in-all some interesting stuff to experiment with here, since I’ve playing about with JSS too this is something I plan to look at in more detail.

Sitecore XDB & GDPR Applied – Rob Habraken

gdpr

Rob opened by saying this was a dull subject. That it may be but it is also a very hot topic and something many clients need to implement very soon so this was a very insightful session for me.

sitecore gdpr

  • Sitecore 9 has GDPR features out of the box and Sitecore 8.2 Update 7  will also have them.
  • 6 Steps to follow to implement GDPR With Sitecore:

IMG_1529

IMG_1532

IMG_1536

IMG_1540

IMG_1542

IMG_1548

Azure Round Table – Tamas Varga

The final session I attended was an Azure Round Table where there were some really good insights from those who have used Sitecore Azure:

Azure

  • Using the provided Azure ARM Templates is a good start but can I can be limiting as time progresses so creating your own is the way to go eventually.
  • There can be problems with CSS and JSS not being published yet when swapping between servers.
  • Testing an Azure Sitecore setup on a development environment and keeping costs down can be a challenge. MSDN provides free credits for subscribers.
  • If using Azure the advice is to move to Sitecore 9.x if you can first as that will make things much easier.

Awards, Quiz & Drinks

At the end of Day 1 I had the privilege of going on-stage and picking up my MVP award with the other 2018 MVPs. I’d seen the MVPs collect their awards in previous years but didn’t think I’d be joining them this year, I felt very proud to be sat alongside everyone. Obviously a few beers were enjoyed afterwards to celebrate.

mvps

Day 2

Sitecore Install Extensions In Action – Robert Senktas

I hadn’t heard of SIX before but having had some experience of using SIF when installing Sitecore 9 this looked interesting.

IMG_1562

  • SIX has a number of powerful features that make it superior to SIF and it support storing sensitive data in Azure Keyvault:

IMG_1564

SIX

  • An early GUI was demo’ed that runs on top of SIX and allowed an Octopus style management of the install process.

softserve

This all looks pretty cool and definitely something I’m going to look into further.

White Hat Hackers Guide To The Internet – Mikkel Ole Romer

IMG_1576

This was the most packed break-out room I saw over the two days.  Mikkel showed some simple Hacking Techniques he’d tried on a list of Sitecore Solutions and the results were quite worrying.

  • He showed us some simple hack’s he’d tried:

IMG_1577

IMG_1580

IMG_1581

  • The results of the test were a little worrying…

IMG_1582 IMG_1584 IMG_1585This session was a bit of an eye opener to say the least. Check your Sitecore installs configuration and patches folks!

 Sitecore & The Blockchain – Jason Bert

Since I have some Bitcoin & Ripple and I’m interested in Crypto and the application of Blockchain technology this seemed like a talk I wouldn’t want to miss.

blockchain

  • Jason used a number of technologies to store the details of a ticket purchase on the Etherium Blockchain.

IMG_1594

IMG_1595

  • Jason used a local Etherium Blockchain testing tool called Ganache but in the real-world this could be slow and potentially costly.

IMG_1596

This was an interesting talk that certainly makes you think about how these technologies could be used in future.

From Forms to Riches – Kamruz Jaman & Mike Reynolds

IMG_1598

Having talked to Kam a bit about what he was going to discuss I was looking forward to a bit of a deep-dive into the new Sitecore 9 forms module and thats exactly what we got.

IMG_1600

  • The metrics stuff and interface looks pretty cool.

IMG_1602

IMG_1605 IMG_1606 IMG_1607

  • We were also shown how to create a custom field and data encryption was discussed.
  • But there is some functionality missing as it’s an first release. If you need to you could build some of this yourself.

IMG_1617

Latest Goodnesss JSS – Alex Shyba & Adam Weber

Having presented a talk on JSS at the Sitecore Sessions in Manchester recently I had a good idea about most of this talk but there was still some really great stuff to see and hear. I got to speak to Alex and Adam in person too and they were really helpful.

jss

IMG_1624

IMG_1625

Rendering level JavaScript was what I was really interested in seeing. This is JSS Components running along-side MVC ones in the same page!.

IMG_1629

It was really cool to see this in action. I’ll be trying this out as soon as I get chance.

IMG_1631

IMG_1633

IMG_1637

IMG_1640

Time to go home

After a few words of thanks to the organisers and attendees for an fantastic SUGCON it was time to head home….After a few more drinks of course.

IMG_1642

What did I get out of SUGCON?

This year I was determined to do more networking and spend time talking to people in the Sitecore Community who I’ve spoke to on-line but never/rarely met. I certainly learnt a great deal from the sessions too but getting to chat to fellow MVPs, Developers, Sitecore Employees who I’ve known online for sometime but not met was my favorite takeaway from the past couple of days. If you didn’t make it this year and are thinking of going next year then I’d highly recommend you get your tickets booked for SUGCON 2019 in London on the 4th & 5th of April. You won’t regret it.

My Sitecore MVP 2018 Journey So Far

Back in late January I was fortunate enough to be awarded Sitecore Technology MVP 2018. For anyone in the Sitecore Community this is a great privilege as there are only 208 Technology MVP’s worldwide and 20 in the UK.

Sitecore_MVP_logo_Technology_2018

I hadn’t got round to writing on my Blog about it at the time so I thought it would be good to talk about my experience so far this year as an MVP and also what my plans are for this year.

Every year, the Sitecore MVP Awards honour individuals with a passion for sharing their knowledge and expertise through active participation in online and offline Sitecore communities.

Sitecore has an fantastic community of developers who really try and help one another out both online and offline and share their knowledge and expertise whenever they can.

If you want to see the full list of Sitecore MVPs for 2018 you can see it here: https://mvp.sitecore.net/MVPs/2018

As an MVP there are a number of benefits; such as getting to give feedback to Sitecore on things they are working on, access to additional resources and Community Groups and gaining early knowledge of future releases & features coming out of Sitecore HQ.

How Do I Become an MVP?

I’ve seen this asked a few times on Twitter, Slack and Stack Exchange etc and I think the consensus is that you shouldn’t aim to become an Sitecore MVP but should instead try and get involved in the Sitecore Community as much as possible.

Share what you learn on a Blog,  get involved in Sitecore Stack Exchange (SSE) by posting both questions and answers, join in on Sitecore Slack anad get involved in your local Sitecore User Group. Maybe do a presentation or two and share your learnings and expertise.

This is a great post on SSE from Mark Cassidy with more ideas of how you can get involved in the Sitecore Community: https://sitecore.stackexchange.com/questions/1689/how-can-i-connect-with-the-sitecore-community.

By getting involved in the Community like this if you feel you’ve contributed enough you can nominate yourself (usually in November) and ask others to recommend you too.

You can read more about the MVP program here: https://mvp.sitecore.net/become-an-mvp

There is also an excellent SSE post here about becoming an MVP by Tamas Varga (who is an Technical Evangelist at Sitecore and works on the MVP Team): https://sitecore.stackexchange.com/questions/5796/how-to-become-a-sitecore-mvp

My Plans For 2018 as an MVP

Since becoming an MVP I’ve tried to continue being active in the Community and have written some useful blog posts on Installing Sitecore 9 Update 1 and Getting Started with JSS.

Part 2 of working with Sitecore JSS is coming up soon and I’ll be giving a talk on this at the next Manchester meetup along with 2 talks from other Sitecore MVPs:

The Sitecore Sessions

London, GB
226 Members

The Sitecore Sessions are a group of events, up and down the country, with an aim of catering for what we hear the community want to know more about.We have been, and contin…

Check out this Meetup Group →

 

I’m planning on giving an overview of installing JSS. I’ll then be going into more detail on and getting up and running and building components. Hopefully this will be one of a number of presentations I’ll get to do this year.

I’m also hoping to build my first Sitecore Module and share it on the Marketplace this year. I’ve got a few interesting ideas so watch this space.

I’m really looking forward to learning more about Sitecore 9 and catching up with the Sitecore Community & other Sitecore MVPs at SUGCON in Berlin next month and the MVP Summit at Symposium later this year.

Lastly I wanted to say thanks to Sitecore and the great Community for recognising my contributions and particularly the MVPs and Sitecore staff that recommended me (you know who you are :-)).

 

Getting Started with Sitecore JSS

I saw a demo of JSS at SUGCON last year by Alex Shyba and it looked really cool. Ever since I’ve been keen to try it out as soon as I could. This post covers the basics of setting up JSS and running a demo React App.
jss-logo
The first stumbling block however was getting an install of Sitecore 9 up and running.
You will need this before you can proceed with the rest of this tutorial so if you don’t have Sitecore 9 installed already then you can read my Blog Post on how to install Sitecore 9 update 1 here.

What is JSS?

JSS is an SDK that allows developers to build websites using Javascript frameworks such as React and Angular. Sitecore is used as a Headless CMS to provide the Sitecore item’s presentation details as JSON. It has full support for the Sitecore Experience Platform, including Experience Editor, Personalization, MV testing and Tracking / Analytics.

One thing that will keep front-end developers happy is that Apps can be built entirely detached from Sitecore and then deployed to Sitecore later. This also means that Sitecore doesn’t need to be installed to build applications with JSS. Apps are deployed to Sitecore using JSS code-first services via the command line.

This just touches on the basics of JSS, you can read more about it and the full install instructions here: https://jss.sitecore.net

Prequisites

  • Sitecore 9 or 9 update 1 (with a licence with JSS included)
  • Node JS version 6.9 or above
  • NPM version 5 or above

JSS Setup Steps

There are a number of steps required to Setup JSS before you can start developing using it. Follow all of these for the purposes of this post.

  1. Download and install the following two JSS server packages in Sitecore (using the package installer) from here: https://dev.sitecore.net/Downloads/Sitecore_JavaScript_Services/90_Tech_Preview/Sitecore_JavaScript_Services_90_Update_1_Tech_Preview.aspx
    1) Server Package (Tech Preview 9.0.1 rev. 180111)
    2) Infrastructure Package (Tech Preview 9.0.1 rev. 180111) – this is optional but is needed if you want to deploy your App to Sitecore via the command line

  2. Apply this to the web.config at the bottom of the system.webServer/handlers section:

    <add verb=* path=sitecorejss_media.ashx type=Sitecore.JavaScriptServices.Media.MediaRequestHandler, Sitecore.JavaScriptServices.Media name=Sitecore.JavaScriptServices.Media.MediaRequestHandler />

  3. Apply this to the web.config inside the system.webServer/modules section:

    <add name=”Sitecore.JavaScriptServices.Ship.ShipFilter” type=”Sitecore.JavaScriptServices.Ship.ShipFilter, Sitecore.JavaScriptServices.Ship” />

  4. Login to Sitecore Desktop on the Sitecore 9 instance you want to use. Switch to the Core database. In the Content Editor Navigate to: /sitecore/system/Settings/Services/API Keys
    and  insert a new API Key item, call it ‘JSS API Key’. Under AllowedControllers, which fill in the field with: “*”. Leave the rest of the fields as is. (more info on this step here). Take a note of the Item ID of the API Key item as you will need it in the next step.
  5. Verify everything works by going to:

    http://your-sitecore-instance/sitecore/api/layout/render/jss?item=/&sc_apikey={YOUR_API_KEY}.

    You should see something like the following in your browser:
    jss-test

Downloading & Testing a Demo App

Were going to use React for this and to keep things simple were going to use the simple React demo.

  1. Pull the JSS Demo source files from here: https://github.com/Sitecore/jss/tree/master/samples/basic-sample-react
  2. Go to IIS and add a ‘jssbasicapp’ as a new binding in IIS
  3. Edit your hosts file (C:\Windows\System32\drivers\etc\hosts) and add the following:

    127.0.0.1 JssBasicApp

    (you can change the name of the app and other settings if you want by editing: jss-basic-app.config)

  4. Open command line and go to the folder where you have downloaded the basic react sample (e.g: C:\Projects\Jss-Demos\samples\basic-sample-react).
    Run:

    npm install

  5. Next Run:

    npm run setup

  6. Next Run:

    npm run deploy-config

    You will be asked: ‘Would you like to configure connection settings to a Sitecore instance?’ – Enter Yes.
    When prompted enter your the Website Folder and Host of your Sitecore instance.

    (If you have any issues with this ensure you have your permissions set so allow the script to run and copy files over to your Sitecore instance)

  7. Lastly Run:

    npm run start

This will build the app and run a WebPack server, finally it should open up a browser showing the basic App at the following url: http://localhost:3001.

This will look like the homepage of a Standard Sitecore 9 install.

The App is not currently using Sitecore for data, it is being provided by local files within the app.

Deploying the App to Sitecore

Finally were ready to deploy the app to Sitecore and hook it up using real Data.

  1. Run:

    npm run deploy-codefirst

  2. Open up: http://jssbasicapp/ – you should see the following:
    jss-deploy1

  3. Lets double check it’s worked correctly by going to your Sitecore instance, opening Content Editor and going to: /sitecore/content/JSSBasicApp. You should see something Similar to:
    jss-tree

  4. Ok lets make a change to a component and re-deploy it to see the change working. Open up \samples\basic-sample-react\src\app\components\Welcome.js from the folder where you installed the demo.
    Edit the following lines to add a H2 tag with ‘Hello JSS’ in it:
    jss-component-update
  5. Open Command Line again and Run:

    npm run deploy-codefirst

  6. Again open up: http://jssbasicapp/ – you should see ‘Hello JSS’ show up:
    jss-deployed-2

  7. Finally go to: /Home in the Experience Editor, you should be able to edit the page as normal even though the Components are provided by JSS.

This is a really basic demo of JSS but it should hopefully show whats possible and get you started with working with JSS.

Props to Alex and his team for doing a great job and addressing the workflow of front-end developers with how they have approached JSS.

Auto-Setting Alt Text For Existing & New Images in Sitecore with Cognitive Services

Alt text on images is important for accessibility but often content editors do not set it or are not sure what to set it to.

I recently had the scenario where a client had thousands of existing images (across a Multisite Solution) with no Alt text entered and was asked to find a solution to add these retrospectively and also to make this easier going forward.

The Robots Are Coming

After considering my options (and reading a bunch of Blog Posts on how others have solved this) I decided to use Sitecore Powershell to set the missing Alt tags. This was because I only needed to run this once and then I won’t need to do this again.

However what should I set the Alt text too? It would be possible to use the image name in Sitecore or other attributes on the image in Sitecore to intelligently name the image. However often images have pretty non-descriptive names and no other data associated with them. An Alt tag of ‘IMG_20170416_085835‘ isn’t a great deal of use to users or screen readers. Therefore I wanted to use a more intelligent way of adding Alt Text.

robots

I’d seen this awesome presentations by Mark Stiles and Rob Habraken & Bas Lijten at Sugcon this year about using Machine Learning to solve problems just like this, and decided this was the way to go.

Mark Stiles has blogged about an full integration that he’s implemented with Microsoft Cognitive Services here: https://www.markstiles.net/blog/2017/2/22/sitecore-cognitive-services/

However I didn’t need all this functionality and this hasn’t been wrapped up into a proper Sitecore Module yet so I decided to go for a simpler approach.

Setting Alt Text for Existing Images

I stumbled across this really useful Post: http://www.pveller.com/image-tagging-automation-with-computer-vision/ by Pavel Veller which is what formed the basis of my script. It goes through each image in the media library and uses Microsoft’s Vision API to look at each image and return some appropriate Alt Text.

However given the number of images I needed to handle and complexity of the Multi-Site solution I’m working on I needed quite a lot more functionality. Therefore my script does the following:

  • Ability to run in test mode to output what it would do if run for real
  • Progress output as the script runs so you know how far through it is
  • Only updating Alt text when there is none set already
  • A CSV report at the end with the info for all images and the Alt text set
  • A list of TemplateIds to Exclude
  • A list of FolderIds to Exclude
  • Full error handling for exceptions
  • Pause for 60 Seconds and continue when hitting the Free API Limit (thanks Pavel Veller for this idea).
  • Tracking of failures/errors
  • Summary at the end of updated text and errors (if any)

Example Output

alt-text-screen-1

Example Summary

alt-text-screen-7

Note that to run this you will need an API key for the Vision API, so go and grab one from here:

https://azure.microsoft.com/en-gb/try/cognitive-services/

Show Me The Script Already

I’ve put the script here on Github and embedded it below: https://gist.github.com/fluxdigital/2b6041c579770f891df1a0da43cdcd63

The outcome of running this was that we auto-set alt text for over 1,500 images and could send the client a csv report of all of the alt text for each image for review afterwards (should they wish to check them, the API is not infallible, especially for Gifs/Pngs and other graphical images). This saved a lot of time for the content editors.

What about new images?

So this is great for the existing images, but how do we make sure that alt text is set in the same way for new images?. After a bit of investigation I decided on this great Module by Tom Dudfield which auto-sets alt tags on save of the image using the same Vision API:

https://marketplace.sitecore.net/en/Modules/A/Alt_Tag_Generator.aspx

This Module even works with the multi-file upload so it’s really good if users upload a lot of images at once and forget to go back and add Alt Text.

I did find and issue with the module where is doesn’t work if you use one of the free API Keys (as the base API url needs to be different), but I’ve fixed that and submitted a pull request to resolve this issue. The Module config will now support setting the base Url (to: https://westcentralus.api.cognitive.microsoft.com/vision/v1.0). Tom has merged my update in and will hopefully release a new version Via NuGet and the Marketplace soon, but in the mean time if you need the update you can find it here:

https://github.com/fluxdigital/AutoAltTags

Once you’ve installed this and configured it with your API key you should be good to go, no more empty Alt text :-).

Thanks to the Sitecore community for all the great posts on this that helped me with this, here are just some of them:

http://jockstothecore.com/optimizing-images-sitecore/

https://sitecorebasics.wordpress.com/2017/08/03/integrating-cognitive-services-to-set-alt-tag-during-image-upload/

https://tomdudfield.com/computer-vision-alt-tags-in-sitecore/

 

Auto-maintaining Sitecore Session State permissions in tempDB after SQL Server restarts

We use SQL Server to maintain our Sitecore sessions which mostly works fine. However as part of the performance boosts recommended by Sitecore the session-state is moved to store session in SQL Server tempDB.

The process is explained here: https://doc.sitecore.net/sitecore_experience_platform/setting_up_and_maintaining/session_state/session_state/walkthrough_configure_a_shared_session_state_database_using_the_sql_server_provider

However, every time that SQL Server is restarted, it recreates tempDB and resets the access rights for users and the session tables. This will result in your Sitecore site going down and an error such as:

System.Data.SqlClient.SqlException: The SELECT permission was denied on the object ‘SessionState’, database ‘tempdb’, schema ‘dbo’. The INSERT permission was denied on the object ‘SessionState’, database ‘tempdb’, schema ‘dbo’. The UPDATE permission was denied on the object ‘SessionState’, database ‘tempdb’, schema ‘dbo’.

And also an angry client and customers :-(.

How do I solve this?

You could re-run the script from the Performance boost download provided by Sitecore (Sessions db performance boost.sql ) but this could happen late at night when no one is monitoring your site and cause downtime.

The best way to solve this and still use tempDB for sessions is to offload this manual task into a stored procedure that runs on Start-up.

The following script will create a Stored Procedure in the Master database that will run each time SQL Server restarts and add your session tables and database user back to tempDB with the right permissions.

USE [master]
GO
IF EXISTS (SELECT * FROM sys.objects WHERE type = ‘P’
and name = ‘AddSitecoreSessionTempDBOwner’)
DROP PROC AddSitecoreSessionTempDBOwner
GO
CREATE PROC AddSitecoreSessionTempDBOwner
AS DECLARE @sql
VARCHAR(500)SELECT @sql = ‘EXEC [master].[dbo].[Sitecore_InitializeSessionState]’ + char(13) +’USE [tempdb]’ + char(13) +’IF NOT EXISTS(SELECT name FROM sys.database_principals WHERE name = ”Sitecore_Sessions”)’ + char(13) +’BEGIN’ + char(13) +’CREATE USER [Sitecore_Sessions] FOR LOGIN [Sitecore_Sessions]’ + char(13) +’ALTER ROLE [db_datareader] ADD MEMBER [Sitecore_Sessions]’ + char(13) +’ALTER ROLE [db_datawriter] ADD MEMBER [Sitecore_Sessions]’ + char(13) +’END’EXEC (@sql)
GO
EXEC sp_procoption ‘AddSitecoreSessionTempDBOwner’, ‘startup’, ‘true’
GO

Just remember to update ‘Sitecore_Sessions’ in the script above to the name of the user in your Sessions Database connection string, then run the script in SQL Server Manager to create the stored procedures that will run on start up.

How do I test this?

It is important to test this to ensure that on a restart of the SQL Server the script kicks in and works it’s magic. First check if the Stored Proceedure is set to run on Startup correctly by running this query:

SELECT name,create_date,modify_date
FROM sys.procedures
WHERE OBJECTPROPERTY(OBJECT_ID, ‘ExecIsStartup’) = 1

You should see the ‘AddSitecoreSessionTempDBOwner’ and ‘Sitecore_InitializeSessionState’ stored procedures listed. If you don’t try running the script above again as something went wrong.

Once these are listed correctly you should carry out a full test by scheduling in a time out of hours when you can reboot the SQL Server machine and check your script runs correctly.

Gotchas

One thing to ensure is running is the SQL Server Agent Service. This needs to be running in order for and startup stored procedures to be executed.

slq-agent

Check this is set to ‘Auto Run’ under startup type. This caught me out on my first test as my Stored Procedure didn’t run correctly on reboot of the SQL Server.

Lastly check your session state tables are collecting session data correctly using a query such as:

select count (*) from [tempdb].[dbo].[SessionState]

That should be it, no more problems with tempDB when SQL Server restarts.

 

Sitecore Stack Exchange Site Needs Your Help!

A while ago Mark Cassidy  started a Stack Exchange Site for Sitecore – our own Sitecore Specific Stack Overflow essentially .  Great idea right?

The Sitecore Stack Exchange Site Needs Your Help!
Calling All Sitecore Developers!

Myself and other Sitecore Community members have been trying to get the site (currently in Beta) to launch.

Due to Sitecore Symposium causing a downturn in activity for over a week we were initially told the site wasn’t going to make it out of Beta :-(.

However the good news yesterday was that Stack Exchange kindly relented and extended the Beta for another two weeks! until the 18/10:

http://meta.sitecore.stackexchange.com/questions/60/extending-the-private-beta-to-10-18

However if this is going to succeed we need more Sitecore developers / users to get involved. There are many of you out there but not enough on the Stack Exchange site.

If you have already signed up for Area51 then please use the site and start contributing.  Go to: https://area51.stackexchange.com/proposals/101710/sitecore and then use the “Visit” link under the “20 days in Beta” box, Or use this link: https://area51.stackexchange.com/proposals/101710/sitecore/visit and log in with the same details you used for Area51

If you haven’t already signed up, then ask for an invite in the #stackexchange channel on slack or tweet me @billyjava and someone will send you an invite.

I’m sure you will agree that our own Stack Exchange site for Sitecore would be a great asset to the Sitecore community and an really useful platform to share knowledge and documentation but if we don’t quickly get more support it won’t make it.

So please do what you can to help and support by asking and answering questions on the Beta site.