SharePoint Content Types (from Hub) and MS changes

Copper Contributor

I'm provisioning a site through a flow, which in turn executes a Site Design (site script) that creates a library and adds several Content Types from a CT hub.

After creating the site I have to wait a few hours before I can attempt to run the site script to add the Content types. The reason for the wait is I think after creating a site, time is required to sycronise the hub to the new site.

This was all working but a few days ago it stopped. A few articles say that there will be a change from a pull to a push model. https://support.microsoft.com/en-us/office/what-s-changed-in-content-type-publishing-609399c7-5c42-4...

In the link above there is a new verb - 'addContentTypesFromHub' but no examples. I tried adding it to the sitescript but it errors. The code below adds the CT to the site and then assigns it to a new library:

 

 {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
    "actions": [
        
        {
            "verb": "createContentType",
            "name": "myCT name",
            "id": "0x010100FDBFA5F33B995B42BCF9E8B473960893",
            "description": "",
            "parentId": "0x0101",
            "hidden": false,
            "group": "myGroup",
            "subactions": []
        },
       

        {
            "verb": "createSPList",
            "listName": "doc2",
            "templateType": 101,
            "subactions": [
                {
                    "verb": "addContentType",
                    "name": "myCT name",
                    "id": "0x010100FDBFA5F33B995B42BCF9E8B473960893"
                }  
            ]
        }
   
    ],
    "bindata": {},
    "version": 1
}

 

 

Any ideas on the new MS changes and way forward? Screenshot of error:

1 Reply

@OrangeJuiceJones In case you haven't found it already, this is now documented with a sample 👉here👈

 

It just needs an array of Content Type IDs, so for more than one, the sampel would look something like this:

{
  "verb": "addContentTypesFromHub",
  "ids": [
    "0x01007CE30DD1206047728BAFD1C39A850120",
    "0x01007CE30DD1206047728BAFD1C39A850121",
    "0x01007CE30DD1206047728BAFD1C39A850122"
  ]
}