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

Could not create new content type via SiteDesign

Open Arturiby opened this issue 6 years ago • 9 comments

Category

  • [x] Bug

Describe the bug

Could not create new content type via SiteDesign. The error 'Parameter parentId references a resource that could not be found.' was thrown. It was working before.

Снимок экрана 2020-05-15 в 01 17 59

Steps to reproduce

  1. Create json site script file with content:

{ "actions": [ { "verb": "createContentType", "name": "Test ct", "group": "Test group", "description": "", "parentId": "0x01", "hidden": false } ] }

  1. Add site script and site design

$siteScript = Get-Content 'test.json' -Raw | Add-SPOSiteScript -Title "Test content type" Add-SPOSiteDesign -Title "Apply test content type" -WebTemplate "64" -SiteScripts $($siteScript.Id)

  1. Apply site design via UI or api

Expected behavior

Content type should be created without any errors

Arturiby avatar May 14 '20 22:05 Arturiby

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

msft-github-bot avatar May 14 '20 22:05 msft-github-bot

Hello @akukharevich

thanks for the heads-up. I have been able to reproduce the reported issue with the provided Site Script and instructions. During my tests, I applied the Site Design on a M365 Group. However, it is possible to work around this issue by using parentName property instead of parentId. This is what the Site Script looks like:

{
    "$schema": "schema.json",
    "actions": [ 
        {   "verb": "createContentType", 
            "name": "Test ct", 
            "group": "Test group", 
            "description": "", 
            "parentName": "Item", 
            "hidden": false 
        }
    ],
    "bindata": {},
    "version": 1
}

Thanks for the feedback.

Regards, Jarbas

JarbasHorst avatar May 15 '20 12:05 JarbasHorst

Hi @JarbasHorst. I understand it. But we have a lot of content types and it was worked before with different site languages. How do you propose to localize parentName? For example English: Document Dutch: Documenten

Also can be a workaround to use ID in ContentType template instead of parentId, parentName.

Arturiby avatar May 15 '20 15:05 Arturiby

Hello @akukharevich

the ID property might be a good alternative in this case. The Site Script below demonstrates how to create a new content type that inherits from the Item content type:

{
    "$schema": "schema.json",
    "actions": [ 
        {   "verb": "createContentType", 
            "name": "Test ct 3", 
            "group": "Test group", 
            "description": "", 
            "id": "0x010049FFDC99D987594DA562D4E98B1429E3", 
            "hidden": false 
        }
    ],
    "bindata": {},
    "version": 1
}

I hope it helps.

Regards, Jarbas

JarbasHorst avatar May 15 '20 16:05 JarbasHorst

Hello again @JarbasHorst.

So, my reported issue affects already developed and existing site scripts for the customer (no problem when scripts support only one English or another language or when it is applied to new sites) I could't re-apply updated scripts to the portal without issues. Lets say previously we applied next to the site:

{
  "actions": [
    {
      "verb": "createContentType",
      "name": "Test ct",
      "group": "Test group",
      "description": "",
      "parentId": "0x01",
      "hidden": false
    }
  ]
}

Due to the SiteDesing provision issue (using parentId) we have to change scripts. Customer would like to add one more CT to the existing site design (changes should be applied to the existing sites also).

I changed site script to

{
  "actions": [
    {
      "verb": "createContentType",
      "name": "Test ct",
      "group": "Test group",
      "description": "",
      "id" : "0x01003572c99771c2485e9d10e0e556fceb7d",
      "hidden": false
    },
    {
      "verb": "createContentType",
      "name": "Test ct new",
      "group": "Test group",
      "description": "",
      "id" : "0x010015ce273bbe1949f69b7e05a05f5f5a2f",
      "hidden": false
    }
  ]
}

parentName is not good for the case because multi language (tested it, it wasn't worked). And when I tried to apply new script sp throws an exception

Снимок экрана 2020-05-18 в 22 19 59

Seems when parentId or parentName are used the sharepoint internally compares using ct name, but when id is used - sharepoint tries to find existing ct with the same id and if that is not found - tries to create but got internal exception 'duplicate name' or similar.

Hope MS will fix the issue soon, for now there is no workaround to make it work with existing scripts and applying to the already exists sites without issues.

Arturiby avatar May 18 '20 19:05 Arturiby

This is stil an issue.

This does not work either:

"parentId": "0x0101"

BrianZhangLarsen avatar May 05 '21 07:05 BrianZhangLarsen

I am too facing this issue, both parentId and parentName parameters do not seem to work...:

"verb": "createContentType", "name": "Projectmap", "description": "Dossier voor een order of project", "parentId": "0x0120D520", "hidden": false, "group": "Aangepaste inhoudstypen",

When I use 'id', it modifies the existing Document Set content type instead of referring to it as a parent.

joostvdlinden avatar May 13 '21 15:05 joostvdlinden

Almost 3 years later, this problem still exists. Only specifying the parentName property works, but lacks flexibility when working with multiple languages.

stefan-at-ilionx avatar Apr 19 '23 12:04 stefan-at-ilionx

Thank you for taking the time to file an issue. We periodically archive older or inactive issues as part of our issue management process, which automatically closes them once they are archived.

If you’d like to understand more about why and how we handle archived (closed) issues, please see Our approach to closed issues.

We appreciate your contribution and if this is still an active issue with the latest SPFx versions, please do resubmit the details. We needed to perform a cleanup, so that we can start with a clean table with a new process. We apologize for the inconvenience this might cause.

github-actions[bot] avatar May 02 '25 14:05 github-actions[bot]