Sitecore 9.2 Version: a New Format for Serialization

In April 2019, I wrote the article announcing the forthcoming Sitecore upgrade. And here it is —  the version 9.2 of Sitecore Experience Platform has been officially released on July 22, 2019.

Today, I will not tell you about all the new features in Sitecore 9.2 but would like to draw your attention to the serialization mechanism.

The process of serialization helps transform data items to text files or memory buffers for their further storage, transfer and reconstruction. It is especially useful for a team of developers who work together on the same project and need to seamlessly synchronize changes between their individual development environments.

In Sitecore 9.2, a new serialization config file appeared in the CMS.Core folder: App_Config\Sitecore\CMS.Core\Sitecore.Serialization.config file.

Sitecore-9.2-serialization-photo

This file contains different parameters. The most interesting of them are:

  • Serialization type (currently, there are two possible variants — default and YAML; keep in mind that by default it is not YAML)

<setting name=”Serialization.SerializationType” value=”default” />

Sitecore-Serialization-YAML-photo

  • Serialization folder (the root of the serialized items)

<setting name=”SerializationFolder” value=”$(dataFolder)/serialization” />

Sitecore-9.2-serialization-photo

  • Field formatters (only works with YAML and defines serialization rules for specific item field types; if you have your custom field type, you will need to develop your own formatter and put it into this section)
    Sitecore-serialization-field-formatters-photo
  • Predicate (only works with YAML; defines which roots should be serialized; by default, two values are used – master and core, that means that the serialization process will serialize all items defined under /Sitecore content path for both core and master database)
  • userPredicate (initially, it’s an empty section; only works with YAML)
    <userPredicate></userPredicate>
    Sitecore-serialization-User-Predicate-photo
  • rolePredicate (initially, it’s an empty section; only works with YAML)
    <rolePredicate></rolePredicate>
    Sitecore-serialization-Role-Predicate-photo

How Can You Execute Serialization Functions in Sitecore? 

There are three options:

1. Do it manually in the Content Editor
Sitecore-9.2-Manual-Serialization-photo

2. Do it automatically by using Sitecore event handlers. For instance:

Serialization-functions-photo3. Use the Sitecore service page 

[your Sitecore cm instance host name]/sitecore/admin/serialization.aspx

Sitecore-Serialization-photo

I’d like to perform both default and YAML serialization manually. Well, I have Sitecore 9.2 installed. Let’s serialize one item using Sample Rendering item (it goes out of the box):

Sitecore-serialization-photo

To serialize this item manually, I have to engage the Developer tab in the Content Editor (right click on any place at the top Content Editor Sitecore ribbon and select Developer).

Sitecore-serialization-photo

Then, select Sample Rendering item, and in the appeared panel click Serialize item.

Serialization-in-Sitecore-photo

As I’ve mentioned before, we have a default serialization (by default). The serialized result is located in the data folder that was specified in the config file (by default App_Data/serialization).

Sitecore-Serialization-photo

Let’s open this file. It looks like this:

Default-Serialization-Sitecore-image

Now, let’s change the default serialization to YAML.

Yaml-serialization-photo

In the config file, change the parameter Serialization type to YAML. But be careful, for the YAML serialization we have a Predicate parameter which serializes all items. In our case, we want to serialize only one item that’s why we change the predicate as follows:

Yaml-serialization-photo

Don’t forget to save changes and go back to the Content Editor. Repeat the serialization process once again. In the folder, the serialized item in the YAML format appears. Take a look at the result:

YAML-serialization-photo

Below you can see the comparison of the default and YAML files:

Serialization-in-Sitecore-9.2-photo

To Sum Up

It’s great news that Sitecore has implemented YAML for serialization as this format is very convenient and widely used by developers.

Some benefits of YAML:

  1. YAML is a human-friendly format
  2. It is not comma separated
  3. It Supports different datatypes
  4. It is used by many technologies and is gaining popularity

Read more about Sitecore Serialization here.

Happy serialization, Sitecorian friends  🙂

Rating: 5.0. From 2 votes. Show votes.
Please wait...

About the author

Vadzim Papko
Vadzim Papko

Vadzim Papko is a Sitecore enthusiast, a senior Sitecore and .Net developer at SaM Solutions. Adhering to the principles of non-stop self-development, he devotes himself to Sitecore innovation and popularization. A certified Sitecore 9 and Xamarin developer. Find him on twitter: @knopikmag.