codeflood logo

Moving fields with Revolver

The Sitecore packager is a brilliant little application for moving things from one Sitecore server to another. One limitation I've run into with it is that it only operates on the item level. If I only need or want to update certain fields of an item, then I have to do it manually.

Or so I did before Revolver anyway. Let me give you a solid example of what I'm talking about. When performing maintenance updates on a Sitecore site I updated the presentation of an item in dev which I needed to deploy up to staging and then production. The item in dev was populated with test data in the content fields but had production data on staging and production. If I use the packager I can only include the item whole which will overwrite the content fields upon deployment.

I could have taken a copy of production and brought it back to dev before commencing maintenance. Hindsight is 20/20... Or I could use Revolver to update the target environments.

To get the content of a field I can use the gf command:

gf -f __renderings

Now I can copy this text by highlighting it in the command window and pressing ctrl-c. To update the field on the target system I can use sf:

sf __renderings 

and pasting the raw content into the above command.

I could have done the same with the content editor and clicking to show raw values on the view tab as well, but with Revolver I can actually create a file with the content for versioning / later retrieval / etc. To write the content of a command to a file, use the echo command:

echo -f c:\temp\layout.xml < (gf -f __renderings)

And to update the layout from file, first move the file to the target server, then execute:

sf __renderings < (echo -i -f c:\temp\layout.xml)

I could also script a bunch of these updates into a single script if multiple items needed single field updates.

The above also brings up an implementation pattern; Presentation should never be defined on an item itself. It should always be defined in template standard values. Even if only a single item will use the presentation. That would prevent the above scenarios from occurring. But also keep in mind that it may not always be the presentation fields you want to migrate. It could be other fields instead such as meta data or product price, etc.

Comments

Leave a comment

All fields are required.