Site Script - Adding column to Site Pages is not inherited by Repost Page content type

Occasional Contributor

Hi,

 

Adding a column to the Site Pages library using the UI has the option "Add to all content types" which seems to be missing in Site Script. So, adding a site column via Site Script as below results that columns is only inherited by the Site Page content type and not the Repost Page.

 

 

"actions": [            
    {
      "verb": "createSPList",
      "listName": "Site Pages",
      "templateType": 119,
      "subactions": [
        {
          "verb": "addSiteColumn",
          "internalName": "PageCategory",
          "addToDefaultView": true
        }
         ...
}

 

 

Results in:

Repost Page not inheritingRepost Page not inheriting

 

This could be solved by modifying the base site content type:

 

"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"
        }
        ...
}  

 

 

So, to my questions:

  1. Is the approach with modifying the base site content type "OK" nowdays or is it violating any practices/rules? Reflections on this?

  2. If 1 is not OK then is it solvable using Site Design/Site Script or will it require alternative approach such as PnP?

NOTE: Want to use Site Design/Site Script and would like to avoid creating own content type in this case.

 

/Adam

0 Replies