2

While implementing workflow for our site, I stumbled upon a Unicorn issue. Creating a page works just fine, but when an editor goes to edit the page, and so creates a new version, Unicorn gives a critical message about fields not matching serialization. The fields mentioned are the ones edited in the 'first version'.

I've looked at the .yml and it seems like when creating a second version of a page, the before edited fields are not serialized to the new version, and as such creating the 'fields not matching serialization' error.

Is this something wrong in our configuration, or is there some other way around this issue?

Example: When creating a page, I've edited the 'Project title'. After publishing, I've edited the 'meta title'. As you can see the project title doesn't show up in version 2.

- Language: en
 Fields:
  - ID: "b5e02ad9-d56f-4c41-a065-a133db87bdeb"
    Hint: __Display name
    Value: Test page
  Versions:
  - Version: 1
    Fields:
    - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
      Hint: __Created
      Value: 20190206T073544Z
    - ID: "3e431de1-525e-47a3-b6b0-1ccbec3a8c98"
      Hint: __Workflow state
      Value: "{FCA998C5-0CC3-4F91-94D8-0A4E6CAECE88}"
    - ID: "5dd74568-4d4b-44c1-b513-0af5f4cda34f"
      Hint: __Created by
      Value: |
        sitecore\publisher
    - ID: "fc67969e-caaf-43a1-a891-58203f17557c"
      Hint: ProjectTitle
      Value: Title changed in the first version
  - Version: 2
    Fields:
    - ID: "25bed78c-4957-4165-998a-ca1b52f67497"
      Hint: __Created
      Value: 20190206T073646Z
    - ID: "3e431de1-525e-47a3-b6b0-1ccbec3a8c98"
      Hint: __Workflow state
      Value: "{190B1C84-F1BE-47ED-AA41-F42193D9C8FC}"
    - ID: "41f598eb-4a49-4b48-a91f-7aa126358f1a"
      Hint: MetaTitle
      Value: Meta title changed in the second version
    - ID: "c8f93afe-bfd4-4e8f-9c61-152559854661"
      Hint: __Valid from
      Value: 20190206T073646Z

We're using Unicorn 4.0.3 and Sitecore 9.0.2

  • When you edit the item, do you create new version every time? Have you tried changing the same field i.e project title when new version is created? I am guessing because no change from version 1 and 2 the field is only displayed once. If it was modified in both versions then the field would be updated. – Anicho Feb 6 at 15:55
  • Hi Anicho, yes every time you edit the item a new version is created. You can indeed change the 'project title' in the second version and then in works, but it seems to me that shouldn't be the issue. I don't think editors have to modify every field for the page to properly serialize. – Alwin Feb 7 at 8:01
  • Hi @Alwin I don't believe it's not, not working. Looks like unicorn will take changes from all versions to paint a complete picture for a single item. Rather than duplicating the field serialization again and again, serializing the same field only if there is a change detected in it. Does that make sense? Finally the general rule of thumb is that don't Unicorn serialize actual content unless, it is for purpose of development and/or testing shouldn't be serialized so my recommendation is to turn it off this will stop the dialog appearing to editors. – Anicho Feb 7 at 8:59
  • Thanks for the explanation! We've indeed decided to no serialize items for the production environment. – Alwin Feb 7 at 15:56
  • please accept my answer if you are happy with it :). – Anicho Feb 7 at 16:15
1

As discussed in comments, should avoid serialising content that is in production and that is being used by content editors.

The following is mentioned on Unicorns readme file on github.

NOTE: When deploying to a Content Editing or Content Delivery server, the Unicorn configuration should be trimmed down from development. Each config file in App_Config/Include/Unicorn has comments at the top designating what environment(s) it should live on. If you opt to use Transparent Sync as a deployment mechanism, make sure you > do not disable the data provider config file.

and

Don't use Unicorn to serialize actively versioned or workflow-enabled content (e.g. non-developer items). You can easily have two people create totally different "version 2" (or even v3, overwriting someone else's v2) content on different locations, and merging those is probably not what you want. It may be relatively safe during initial development if sharing test content, but be wary.

source: Unicorn Github

Also worth noting regarding serialisation of content is that, if it's being serialised and checked into git, for purposes of Continous Delivery and Continous Integration. If you you run a sync with items you've serialised at development level when deploying to production you run the risk of overwriting live content with developer content, this is why it is best to avoid serialising much under /sitecore/content tree and it's worth ensuring that your unicorn configs are air tight as possible to prevent this.

As for how the versions are serialised, from the assessment done in conversation of comments, we can see that it'll only ever serialise a field if there is a value. It will always store this value against the version it was first, placed in, however if the value changes then it'll add the field again against the version it was changed in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.