Forum Discussion
Standard Folder Structure for Organization Template Schema
- Aug 06, 2022
By default Get-SPOSiteScriptFromWeb command will not include folder structure from document library.
For that you need to update Site Design / Script JSON before adding it as Organization Template. There you can provision folder using list sub action called "addFolder".
Official JSON Schema for supported action: https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.jsonI have created sample JSON schema to provision folder inside document library:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json", "actions": [ { "verb": "createSPList", "listName": "MyDocuments", "templateType": 101, "subactions": [ { "verb": "setDescription", "description": "List of Customers and Orders" }, { "verb": "addFolder", "path": "Folder1" }, { "verb": "addFolder", "path": "Folder2" }, { "verb": "addFolder", "path": "Folder1/Folder11" } ] } ], "version": 2 }
Hope it will help to you and if it does then request you to mark this as answer or like it.
By default Get-SPOSiteScriptFromWeb command will not include folder structure from document library.
For that you need to update Site Design / Script JSON before adding it as Organization Template. There you can provision folder using list sub action called "addFolder".
Official JSON Schema for supported action: https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json
I have created sample JSON schema to provision folder inside document library:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
"actions": [
{
"verb": "createSPList",
"listName": "MyDocuments",
"templateType": 101,
"subactions": [
{
"verb": "setDescription",
"description": "List of Customers and Orders"
},
{
"verb": "addFolder",
"path": "Folder1"
},
{
"verb": "addFolder",
"path": "Folder2"
},
{
"verb": "addFolder",
"path": "Folder1/Folder11"
}
]
}
],
"version": 2
}
Hope it will help to you and if it does then request you to mark this as answer or like it.
kalpeshvaghela Thanks for this. I used this structure in my template but am getting errors. Here's the first part of my template, which I ran through a json linter to make sure the json was valid.
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json",
"actions": [{
"verb": "createSPList",
"listName": "XXXXXX Project Name",
"templateType": 101,
"subactions": [{
"verb": "setDescription",
"description": "Standard Project File Structure"
},
{
"verb": "addFolder",
"path": "00-RFQ & Interview Information"
},
{
"verb": "addFolder",
"path": "A-Project Administration"
},
{
"verb": "addFolder",
"path": "A-Project Administration/A1-Proposals & Contracts"
},
.....
Here are the errors I receive:
At line:2 char:14
+ "$schema": "https://developer.microsoft.com/json-schemas/sp/site- ...
+ ~
Unexpected token ':' in expression or statement.
At line:4 char:19
+ "verb": "createSPList",
+ ~
Unexpected token ':' in expression or statement.
At line:8 char:27
+ "verb": "setDescription",
+ ~
Unexpected token ':' in expression or statement.
At line:12 char:27
+ "verb": "addFolder",
+ ~
Unexpected token ':' in expression or statement.
At line:16 char:27
+ "verb": "addFolder",
+ ~
Unexpected token ':' in expression or statement.
At line:20 char:27
+ "verb": "addFolder",
....
Any idea why these errors could be happening?
- kalpeshvaghelaAug 08, 2022Iron Contributor
It seems that error is not for the part which you have shared because I tried below schema where I used same as you there it worked fine.
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/site-design-script-actions.schema.json", "actions": [ { "verb": "createSPList", "listName": "MyDocuments3", "templateType": 101, "subactions": [ { "verb": "setDescription", "description": "Standard Project File Structure" }, { "verb": "addFolder", "path": "00-RFQ & Interview Information" }, { "verb": "addFolder", "path": "A-Project Administration" }, { "verb": "addFolder", "path": "A-Project Administration/A1-Proposals & Contracts" } ] } ], "version": 2 }
Is is possible for you to share other part of your template?
- llambert1110Aug 08, 2022Copper ContributorI got it working. I was missing part of my command when I was copying and pasting, once I figured this out, the format you suggested worked perfectly. Thanks.