sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Inconsistency in 'Site template JSON schema' article

Open sympmarc opened this issue 3 years ago • 2 comments

In the section for addContentTypesFromHub, it states: "Once addContentTypesFromHub is applied on a site, the addContentType subaction on a list will be able to add it to the list by name."

But in the addContentType section, it states "Currently we do not support adding enterprise content types."

I just tested addContentType to add a Content Type I had added using addContentTypesFromHub, and it worked by providing the name of the Content Type only - not also the id.

My suggestion would be to amend the addContentType note, as it seems to be incorrect.

One caveat, though: the Content Type added to the site using addContentTypesFromHub shows the current site ('Finance') as the Source, whereas a Content Type added manually from the CTH shows 'Content type hub', as shown in the screenshot below. This seems like a bug.

image


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

sympmarc avatar Sep 23 '22 15:09 sympmarc

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Sep 23 '22 15:09 ghost

I'm using two Site Scripts combined into a Site Template for this

_DepartmentBase.json

The Content Type with the id=0x0101008A49CF890E9DDF4BBC1B9B2FB2A4B45001 is named Policy.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
  "actions": [
    {
      "verb": "joinHubSite",
      "hubSiteId": "da791064-e2aa-4df6-aa51-5213cf5311c7"
    },
    {
      "verb": "addContentTypesFromHub",
      "ids": ["0x0101008A49CF890E9DDF4BBC1B9B2FB2A4B45001"]
    }
  ]
}

Policies.json

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
  "actions": [
    {
      "verb": "createSPList",
      "listName": "Policies",
      "templateType": 101,
      "subactions": [
        {
          "verb": "addContentType",
          "name": "Policy"
        },
  ...

sympmarc avatar Sep 23 '22 15:09 sympmarc