Updating base content type - Violation?

Occasional Contributor

Hi,

 

I have a Site Script where I add Site Columns to the Site Pages library. My issue is when adding site columns via site script then the Repost Page content type is not inheriting the added columns, only the Site Page content type. Adding a column via the UI works as there is an option "Add to all content types" which is missing in site script.

 

Below Site Script fails to have both the Site Page and Repost Page to inhering the added column:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
  "actions": [            
    {
      "verb": "createSPList",
      "listName": "Site Pages",
      "templateType": 119,
      "subactions": [
        {
          "verb": "addSiteColumn",
          "internalName": "PageCategory",
          "addToDefaultView": true
        },
        ....
      }
    ]
}

 

Something that works though is to add the columns to the base site content types however is this "OK" or is this approach violating recommended practices/rules?

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
  "actions": [
    {
      "verb": "createContentType",
      "name": "Site Page",
      "description": "Create a new site page",
      "hidden": false,
      "parentName": "Document",
      "subactions":
        [
            {
              "verb": "addSiteColumn",
              "internalName": "PageCategory"
            }           
        ]
    },
    {
      "verb": "createContentType",
      "name": "Repost Page",
      "description": "Used to create a News link post. If deleted, the News link option will be disabled for users.",
      "hidden": false,
      "parentName": "Site Page",
      "subactions":
        [
          {
            "verb": "addSiteColumn",
            "internalName": "PageCategory"
          }
        ]
    },        
    {
      "verb": "createSPList",
      "listName": "Site Pages",
      "templateType": 119,
      "subactions": [
        {
          "verb": "addContentType",
          "name": "Site Page"          
        },
        {
          "verb": "addContentType",
          "name": "Repost Page"
        }
        ...
      ]
   }
}

 

NOTE: Know that PnP can be used however would like to use Site Design/Site Script and would also like to skip creation of own content types.

0 Replies