Could not create new content type via SiteDesign
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.
Steps to reproduce
- Create json site script file with content:
{
"actions": [
{
"verb": "createContentType",
"name": "Test ct",
"group": "Test group",
"description": "",
"parentId": "0x01",
"hidden": false
}
]
}
- 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)
- Apply site design via UI or api
Expected behavior
Content type should be created without any errors
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
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
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.
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
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
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.
This is stil an issue.
This does not work either:
"parentId": "0x0101"
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.
Almost 3 years later, this problem still exists. Only specifying the parentName property works, but lacks flexibility when working with multiple languages.
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.