Skip to main content

Microsoft

Sitecore Error: “The Field is not a Layout/Renderings field”

When working in the Sitecore content editor, have you ever seen this error message when you try to select a content item? “The field is not a layout/renderings field”. I encountered this error while consulting for a client, and thousands of content items were affected. This also seemed to be a fairly unusual error, and we were stumped.

Error: The field is not a layout/renderings field

Dramatic reenactment.

Exception: System.InvalidOperationException
Message: The field is not a layout/renderings field
Source: Sitecore.Kernel
   at Sitecore.Data.Fields.LayoutField.GetFieldValue(Field field)
   at Sitecore.Shell.Applications.ContentEditor.LayoutField.BuildGrid()
   at Sitecore.Shell.Applications.ContentEditor.LayoutField.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   ...

It took some reaching out on the Sitecore Forums to determine what this error really meant: Somewhere in our content tree was a template item that contained a “Layout” field.  The Layout field type is not intended for use with content items.  Any template that contains such a field will trigger the above error on all associated content. The good news is that only content items that use your bad template will see this error. The bad news is, if your IA is complex enough, zeroing in on your bad template becomes quite the guessing game. After all, you cannot view the affected item’s details to see which templates it is using. We couldn’t easily point to a single template as the culprit, as this Sitecore instance had hundreds of templates and very heavily utilized template inheritance.
To eliminate the guess work, here’s a query I wrote that you can plug into XPath Builder to find the offending templates. (The GUID in the query references the standard Template type.)

/sitecore/templates//*[@@templateid='{AB86861A-6030-46C5-B394-E8F99E8B87DB}']//*[@Type='Layout']

The xpath query shows which tempalte is using the "Layout" field type.

Found you.


To my knowledge, Sitecore’s “__Final Renderings” system item is the only item in the tree that should be using the Layout template field. Therefore, anything not named “__Final Renderings” is what you are looking for. (In older versions of Sitecore, this system item is just called “__Renderings”.)
System Types >> Layout

Never use the System Types >> Layout field.


After the fact, we discovered that a CMS user had edited a heavily-inherited template, adding a new field and assigning it the “Layout” field type just to see what it was. This leads into our bigger takeaway: Be very careful when changing your existing templates, and always test your template changes right away. Making experimental changes is a great way to learn how a system works, but is also a great way to mess up that system. For this style of learning, a dedicated, isolated instance is your best friend.
Note: At the time of the original incident, I did not know what I was looking for, and had not yet written the above query. How I actually found the root cause involved both a conversation with Sitecore CTO John West and a temporary rewrite of a Sitecore pipeline. That’s a tale for another post.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Jacob King

Jacob King is a Senior Technical Consultant for Perficient, specializing in Sitecore solutions. He lives in Indianapolis with his wife and son.

More from this Author

Categories
Follow Us