Expand Minimize

Avoid definition of ContentTypes in ListTemplates.

ContentTypes which are defined in a ListTemplate are not re-usable. Better define the ContentType separately and reference the ContentType in the ListTemplate.

CheckId SPC055503
TypeName AvoidContentTypesInListDefinitions
Severity CriticalWarning
Type ListTemplate

Remove the ContentType from the ListTemplate and replace it with a ContentTypeRef reference to the separately defined ContentType:
Bad Practice

<List xmlns:ows="Microsoft SharePoint" Title="Tasks" FolderCreation="TRUE" ... >
   <MetaData>
      <ContentTypes>
         <ContentType ID="0x010100EED05E02DB9F4831932432C1B47334B201" Name="MyContentType" ... >
         ...
      </ContentTypes>
   ....

Good Practice
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
   <ContentType ID="0x010100EED05E02DB9F4831932432C1B47334B201" Name="MyContentType" ... >
</Elements>

<List xmlns:ows="Microsoft SharePoint" Title="Tasks" FolderCreation="TRUE" ... >
   <MetaData>  
      <ContentTypes>
         <ContentTypeRef ID="0x010100EED05E02DB9F4831932432C1B47334B20" />
      </ContentTypes>
      ...
</List>

To suppress this violation in XML SharePoint code add the following comment right before the XML tag which causes the rule violation. Learn more about SuppressMessage here.

<!-- "SuppressMessage":{"rule":"SPC055503:AvoidContentTypesInListDefinitions","justification":"Provide reason for suppression here"} -->
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.