Aug 05 2022 11:06 AM
I would like to create an organization template for hub users, that automatically adds a default folder structure with subfolders. I started by creating a sample site and retrieved its schema. Now I believe I need to trigger a flow in that schema to create the folder structure based on the folder path in my sample document library. I was able to get the flow to run manually when I knew the destination but the catch is, I don't know the destination yet because I want this to run when users select our site template. What should my power app be like? or am I going about that all wrong?
Aug 05 2022 11:21 AM
@llambert1110 You can try using Site templates. Site templates can be used each time a new site is created to apply a consistent set of actions. Site templates created using custom site scripts will display in the From your organization tab in the site template gallery.
Check this to get started on site templates - https://support.microsoft.com/en-us/office/apply-and-customize-sharepoint-site-templates-39382463-0e...
Aug 05 2022 11:33 AM
Aug 05 2022 10:35 PM
Solution
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.
Aug 06 2022 07:57 AM
@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?
Aug 07 2022 09:23 PM
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?
Aug 08 2022 09:42 AM