0

We are trying to create a site design with SharePoint document library with folders and sub folders along with custom permissions. I know how to create a document library but not sure how can i create a folders and sub folders and add Custom permissions in the JSON Schema Any help is appreciated

$adminUPN="admin user name"
$orgName="mytest"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com/ -Credential $userCredential

$docscript='{
"$schema": "schema.json",
"actions": [
    {
        "verb": "createSiteColumn",
        "fieldType": "Text",
        "internalName": "siteColumn1Text",
        "displayName": "Project Status", 
        "isRequired": false,
        "group": "Contoso Custom",
        "enforceUnique": true
    },
    {
        "verb": "createSiteColumn",
        "fieldType": "Number",
        "internalName": "siteColumn2Number",
        "displayName": "Effort in Days",
        "isRequired": false
    },
    {
        "verb": "createSiteColumn",
        "fieldType": "Note",
        "internalName": "siteColumn3Note",
        "displayName": "Meeting Notes",
        "isRequired": false
    },
    {
        "verb": "createSiteColumn",
        "fieldType": "User",
        "internalName": "siteColumn4User",
        "displayName": "Project Owner",
        "isRequired": false
    },
    {
        "verb": "createContentType",
        "name": "Contoso Projects",
        "description": "custom list content type",
        "parentName": "Item",
        "hidden": false,
        "subactions":
        [
            {
                "verb": "addSiteColumn",
                "internalName": "siteColumn1Text"
            },
            {
                "verb": "addSiteColumn",
                "internalName": "siteColumn2Number"
            },
            {
                "verb": "addSiteColumn",
                "internalName": "siteColumn3Note"
            }
        ]
    },
    {
        "verb": "createSPList",
        "listName": "MytestLibrary",
        "templateType": 101,
        "subactions": 
        [
            {
                "verb": "setDescription",
                "description": "Custom document library to illustrate SharePoint site scripting capabilities - spring 2018"
            },
            {
                "verb": "addContentType",
                "name": "Contoso Projects"
            },
            {
                "verb": "addSiteColumn",
                "internalName": "siteColumn4User",
                "addToDefaultView": true
            },
            {
                "verb": "addSPField",
                "fieldType": "DateTime",
                "displayName": "Delivery Date",
                "internalName": "spField1DateTime",
                "isRequired": true,
                "addToDefaultView": true
            },
            {
                "verb": "addSPView",
                "name": "Contoso Projects by Effort",
                "viewFields": 
                [
                    "ID", 
                    "Title",
                    "siteColumn1Text",
                    "siteColumn2Number",
                    "siteColumn3Note",
                    "siteColumn4User",
                    "spField1DateTime"
                ],
                "query": "<OrderBy><FieldRef Name=\"Title\" /><FieldRef Name=\"siteColumn1Text\" Ascending=\"FALSE\" /></OrderBy><Where><Gt><FieldRef Name=\"siteColumn2Number\"/><Value Type=\"Number\">5</Value></Gt></Where>",
                "rowLimit": 100,
                "isPaged": true,
                "makeDefault": true
            }
        ]
    }
],
"bindata": { },
"version": 1

}'

Add-SPOSiteScript  -Title "Custom Libray" -Content $docscript -Description "Creates library for tracking customer contact information"
Add-SPOSiteDesign -Title "Contoso customer tracking" -WebTemplate "64" -SiteScripts "b0179831-f9a3-47c5-8476-eb6113e9bcef" -Description "Tracks key customer data in a library"
0

Files/Folders provisioning as well as creating custom permissions for List and Libraries is not supported yet via Site Scripts.

Reference - Site Design JSON Schema

2
  • Can we use flow to create folder and then apply the schema docs.microsoft.com/en-us/sharepoint/dev/… Apr 18 '19 at 16:20
  • Yes via flow you can do that. But you will have to create HTTP request yourself for each folder/subfolder and for custom permissions as well. So, you can create a Site script which will trigger flow and then perform these actions Apr 18 '19 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.