Imagine you're building an automated system that creates new SharePoint sites whenever someone adds an item to a list - like a magical factory that produces fully-formed websites! That's exactly what we're going to build together. Let's break this down into manageable pieces and walk through each step.
Before we dive in, let's understand what our automation will do:
graph TD
A[New Item Added to JEFF List] -->|Triggers| B[Power Automate Flow]
B -->|Makes| C[HTTP Request]
C -->|Creates| D[New SharePoint Site]
D -->|Based on| E[PnP Template]
D -->|Adds to| F[Case Management Hub]
D -->|Grants Permissions to| G[Big Permish Group]
E -->|Copied from| H[Terry Template Site]
First, we need to capture the essence of the Terry Template site into a PnP template. Think of this like taking a photograph of a room so you can recreate it exactly somewhere else.
# Install PnP PowerShell if you haven't already
Install-Module -Name "PnP.PowerShell" -Force -AllowClobber
# Connect to the Terry Template site
Connect-PnPOnline -Url "https://mordinilaw.sharepoint.com/teams/TerryTemplate" -Interactive
# Create the template
$templatePath = "C:\Templates\TerryTemplate.xml"
Get-PnPSiteTemplate `
-Out $templatePath `
-Handler Lists,Fields,ContentTypes,Pages,Navigation,Files,CustomActions `
-IncludeAllPages `
-PersistBrandingFiles `
-Force
Open the template file and ensure it contains all necessary components. You might see something like this:
<?xml version="1.0"?>
<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2021/03/ProvisioningSchema">
<pnp:Preferences>
<pnp:Parameters>
<!-- Template parameters will be here -->
</pnp:Parameters>
</pnp:Preferences>
<!-- Rest of your template configuration -->
</pnp:Provisioning>
Now let's create the flow that will orchestrate our site creation. Think of this as setting up a series of dominoes that will fall in perfect sequence.
- Go to make.powerautomate.com
- Click "Create" → "Automated cloud flow"
- Name your flow: "Create Site from JEFF List"
- Choose trigger: "When an item is created in SharePoint"
Configure the trigger with these settings:
Site Address: [Your SharePoint site with JEFF list]
List Name: JEFF
This is where the magic happens. We'll use the SharePoint REST API to create our site:
{
"Body": {
"request": {
"__metadata": {
"type": "Microsoft.SharePoint.Portal.SPSiteCreationRequest"
},
"Title": "@{triggerBody()?['Title']}",
"Url": "https://mordinilaw.sharepoint.com/sites/@{triggerBody()?['SiteUrl']}",
"WebTemplate": "STS#3",
"Owner": "@{triggerBody()?['Author']?['Email']}",
"HubSiteId": "[Case Management Hub ID]",
"Description": "Site created from JEFF list"
}
},
"Uri": "https://mordinilaw.sharepoint.com/_api/SPSiteManager/Create",
"Headers": {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose",
"Authorization": "Bearer @{outputs('Get_SharePoint_access_token')?['access_token']}"
},
"Method": "POST"
}
We need to give SharePoint a moment to create the site. Add a "Delay" action:
Duration: 2 minutes
Add another HTTP request to apply our template:
{
"Uri": "https://mordinilaw.sharepoint.com/sites/@{triggerBody()?['SiteUrl']}/_api/web/ApplyPnPTemplate",
"Method": "POST",
"Headers": {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
},
"Body": {
"templatePath": "[Your template path]"
}
}
Add an action to grant permissions to the "Big Permish" group:
{
"Uri": "https://mordinilaw.sharepoint.com/sites/@{triggerBody()?['SiteUrl']}/_api/web/roleassignments/addroleassignment(principalid=@{variables('BigPermishGroupId')},roledefid=1073741829)",
"Method": "POST",
"Headers": {
"Accept": "application/json;odata=verbose",
"Content-Type": "application/json;odata=verbose"
}
}
Let's set up a proper testing process:
-
Create a test item in the JEFF list with these values:
Title: Test Site Creation SiteUrl: test-site-creation-001
-
Monitor the flow execution in real time:
- Open the flow
- Click "Run History"
- Watch each step execute
-
Common Issues and Solutions:
Issue | Solution |
---|---|
"Access denied" | Check flow connections and permissions |
Template not applying | Verify template path and format |
Site creation fails | Check URL format and availability |
Permissions not set | Verify group ID and role definition |
Your JEFF list should have these columns:
Title (Single line of text) - Required
SiteUrl (Single line of text) - Required
- Description: "Will be used in site URL - no spaces or special characters"
- Validation formula: =AND(LEN([SiteUrl])>0,ISERROR(FIND(" ",[SiteUrl])))
RequestedBy (Person or Group) - Required
- Default value: [Me]
-
Site Naming Convention:
- Use lowercase letters
- Avoid spaces and special characters
- Example: "case-smith-2024" instead of "Case Smith 2024"
-
Error Handling:
- Add condition checks before each major step
- Include email notifications for failures
- Log all operations
-
Maintenance:
- Review flow runs weekly
- Update template monthly
- Document all customizations
-
Security:
- Regular permission audits
- Review site creation logs
- Monitor usage patterns
sequenceDiagram
participant U as User
participant J as JEFF List
participant F as Flow
participant S as SharePoint
participant H as Hub
U->>J: Adds new item
J->>F: Triggers flow
F->>S: Creates site
S-->>F: Site created
F->>S: Applies template
S-->>F: Template applied
F->>S: Sets permissions
S-->>F: Permissions set
F->>H: Associates with hub
H-->>F: Association complete
F->>U: Sends notification
If your site creation process encounters issues, follow these steps:
-
Check Flow History:
- Look for red X marks
- Read error messages carefully
- Note which step failed
-
Verify Permissions:
- Flow connection permissions
- User permissions
- Site collection admin rights
-
Template Issues:
- Check template file accessibility
- Verify template format
- Look for missing components
-
Still stuck? Here's your checklist:
- Screenshot the error
- Note the time of failure
- Document the steps taken
- Contact support with details
Remember: Every error is an opportunity to make your automation more robust!