Sitecore AddVersion returns null

In a multi-lingual build we’d given the user a new toolbar button to create a copy of the given item in a given language. The logic behind the scenes would create a version of the new item in the destination language, scan the original item and copy all the field values to the destination. It would also then reset things like workflow on the destination item.

As part of this logic we’d call:

but would sometimes find itemTo would be null.

With the help of support, they pointed us towards the <sites> configuration and the following attribute:
filterItems: If true, the site will always show the current version of an item (without publishing) and advised this could be causing the issue. This setting can be manipulated programatically via setting:

So your final code would then be:

Enjoy your new versions!

One thought on “Sitecore AddVersion returns null

Leave a Reply

Your email address will not be published. Required fields are marked *