Skip to main content

Build an Overtime Timesheet App in Power Apps — Part 18: Build a Setup Flow That Creates the Lists

· 39 min read
Jagdish Kumawat
Founder @ Dewiride

The Overtime Timesheet app needs three SharePoint lists and a library, set up exactly as Part 2 made them by hand. This part builds one flow that creates all of them on any site, with every column, setting and starting item, and that can run again without creating anything twice.

This is Part 18 of a 22-part series.

  1. Part 1: Plan the App and Set Up the Demo Organization
  2. Part 2: Create the SharePoint Site and Lists
  3. Part 3: Keep Overtime Private with SharePoint Permissions
  4. Part 4: Create the Solution, Environment Variables and Canvas App
  5. Part 5: Build the Home Screen
  6. Part 6: Build the Log Overtime Screen
  7. Part 7: Build the My Overtime Screen
  8. Part 8: Build the Approval Flow for Teams and Outlook
  9. Part 9: Show Approvers What's Waiting
  10. Part 10: Build the Departments Screen
  11. Part 11: Build the Reports Screen
  12. Part 12: Import the Old Excel Timesheet
  13. Part 13: Create the Monthly Payroll Workbook with Office Scripts
  14. Part 14: Create the Payroll Workbook from the App
  15. Part 15: Build the Power BI Overtime Report
  16. Part 16: Share the App and Add It to Microsoft Teams
  17. Part 17: Manage Joiners, Movers and Leavers
  18. Part 18: Build a Setup Flow That Creates the Lists (you are here)
  19. Part 19: Set SharePoint Permissions from the Setup Flow (coming soon)
  20. Part 20: Run the Solution Checker and Export the Solutions (coming soon)
  21. Part 21: Install the App in a New Environment (coming soon)
  22. Part 22: Recap, Production Checklist and Next Steps (coming soon)

Everything the app reads and writes lives on one SharePoint site: Departments, OvertimeEntries, Settings and the Payroll Exports library. Part 2 created them by hand, column by column. Anyone installing the app on another site would have to repeat every one of those clicks, and a single typo in an internal name breaks the app. This part turns that work into a flow, Set Up Overtime Timesheet, in a solution of its own. Part 19 adds the permissions from Part 3 to the same flow.

What You'll Build​

The flow's steps, in order:

  1. Manually trigger a flow, with three inputs: the site's address and the Object IDs of the payroll and admins groups.
  2. List definitions (Compose): the three lists and the library, with their columns and settings, as JSON.
  3. Check the site: stops the run if the address is wrong.
  4. For each list (Apply to each):
    1. Find the list, then If the list is missing, with Create the list in its True branch.
    2. If Title should be hidden: make the Title column optional, hide it in the forms and take it out of the view.
    3. If Title should be unique: make Title unique.
    4. For each column: Find the column, then If the column is missing, with Create the column.
    5. Update the list settings: description, attachments, versions, navigation, search and validation.
  5. Settings items (Compose) and For each setting: add the two group IDs to the Settings list, when they're missing.
  6. Find the Setup folder, then If the Setup folder is missing, with Create the Setup folder in the library.

The finished flow, with the three loops collapsed:

The Set Up Overtime Timesheet flow in the designer: Manually trigger a flow, List definitions, Check the site, For each list with 6 Actions, Settings items, For each setting with 2 Actions, Find the Setup folder, and If the Setup folder is missing with 2 Cases

How It Works​

  • The lists are data. One JSON array describes every list: its name, address, settings and columns. Every later step reads from it, so the lists are described in one place, and adding a column means adding one entry.
  • Every step looks before it creates. A list, a column, a settings item or a folder is created only when it's missing. A second run finds everything in place.
  • One solution of its own. The flow runs before the app is installed: the app's environment variables point at lists, and the lists have to exist first. So the flow lives in a second solution, Overtime Timesheet Setup, with its own SharePoint connection reference.
  • REST requests, standard licences. Every SharePoint step is Send an HTTP request to SharePoint, from the standard SharePoint connector (How to Use Send an HTTP Request to SharePoint). Microsoft 365 licences include cloud flows with standard connectors (Power Automate seeded licenses), so it costs nothing extra.
  • What stays manual. Creating the site itself, and its regional settings: the locale and time zone belong to the organization installing the app, so they're set by hand in Step 1. The permissions come in Part 19.

Prerequisites​

  • Part 17 completed.
  • Permission to create a SharePoint site, for the test site.

Step 1: Create an Empty Test Site​

Test the flow on a site of its own, never on the app's site from Part 2: the flow creates and changes lists, and an empty site is exactly what a new installation starts from. On the SharePoint start page, I selected Build, then Site under Start building (How to Create a SharePoint Communication Site).

The template window opened with names such as TemplateSelectionTitle where its labels should be. Closing it and reloading the page brought the labels back (Fixed: SharePoint Shows TemplateSelectionTitle Instead of Select a Site Template). Then Communication site, the Blank template, now the first of twelve, and Use template:

SettingValue
Site nameOvertime Timesheet Test
Site descriptionTest site for the Overtime Timesheet setup flow.
Site address/sites/OvertimeTimesheetTest
LanguageEnglish

The Set up your site form with Site name Overtime Timesheet Test marked available, the description Test site for the Overtime Timesheet setup flow., the site address https://contoso.sharepoint.com/sites/OvertimeTimesheetTest marked available, the language English, and the Create site button outlined in red

The new site came up with Pacific Time and the English (United States) locale, as every new site here does. I set it like the app's site, under Site settings > Regional settings:

Its Site contents had only what SharePoint creates with every site:

Site contents of the Overtime Timesheet Test site, listing only Documents, Form Templates, Site Assets, Style Library, Events and Site Pages

Step 2: Create the Setup Solution​

In Power Apps, on Solutions, select New solution (How to Create a Solution and Publisher in Power Apps):

FieldValue
Display nameOvertime Timesheet Setup
NameOvertimeTimesheetSetup
PublisherDewiride (Dewiride), from Part 4
Version0.1.0.0
Set as your preferred solutionTicked
Description (under More options)Creates the SharePoint lists and library that the Overtime Timesheet app needs, on any site. Run its flow once, before you install the app.

The Publisher drop-down opened only when I selected its arrow.

The New solution panel with Display name Overtime Timesheet Setup, Name OvertimeTimesheetSetup, Publisher Dewiride (Dewiride), Version 0.1.0.0, Set as your preferred solution ticked and outlined in red, and the description under More options

Set as your preferred solution matters: new flows go into the preferred solution, and with the app's solution still preferred, the flow would land there too (Fixed: A New Cloud Flow Shows Up in Two Solutions in Power Automate).

Step 3: Create the Connection Reference​

In the new solution, select New > More > Connection Reference (How to Create a Connection Reference in a Solution in Power Apps):

FieldValue
Display nameOvertime Timesheet Setup SharePoint
Namedewiride_OvertimeTimesheetSetupSharePoint
DescriptionSharePoint connection for the flow that sets up the Overtime Timesheet lists and library on a site.
ConnectorSharePoint
ConnectionYour SharePoint connection, chosen for you

The New Connection Reference panel with Display name Overtime Timesheet Setup SharePoint, Name dewiride_ OvertimeTimesheetSetupShareP…, the description, Connector SharePoint and Connection admin@example.com

Every SharePoint step in the flow connects through it. Whoever imports the solution later picks their own connection for it.

Step 4: Create the Flow and Its Inputs​

In the solution, select New > Automation > Cloud flow > Instant (How to Create an Instant Cloud Flow in a Solution in Power Automate). Name it Set Up Overtime Timesheet, choose Manually trigger a flow, and select Create:

The Build an instant cloud flow window with Flow name Set Up Overtime Timesheet, Manually trigger a flow selected under Choose how to trigger this flow, and the Create button outlined in red

The trigger takes three Text inputs (How to Add a Text Input to a Manually Triggered Flow in Power Automate):

InputDescriptionIn expressions
Site URLThe address of the SharePoint site, such as https://contoso.sharepoint.com/sites/OvertimeTimesheettriggerBody()?['text']
Payroll group IDThe Object ID of your payroll group in Microsoft Entra, such as Overtime PayrolltriggerBody()?['text_1']
Admins group IDThe Object ID of your app admins group in Microsoft Entra, such as Overtime AdminstriggerBody()?['text_2']

The Manually trigger a flow trigger with three inputs: Site URL, Payroll group ID and Admins group ID, each with its description, and Add an input below them

The two group IDs end up in the Settings list, where the app looks for them (Part 5).

Created from the solution in Power Apps, the flow opened in the classic designer. I added the inputs and the next step there and saved. For the rest, I opened the flow from Power Automate's Solutions page: the solution, then the flow, then Edit. It opened in the new designer.

Step 5: Describe the Lists in List Definitions​

Under the trigger, add a Compose and rename it List definitions (How to Use the Compose Action in Power Automate). Its input is a JSON array with one object per list:

PropertyWhat it holds
titleThe list's name
urlIts address on the site: Lists/<name> for a list, the bare name for a library
template100 for a list, 101 for a document library
descriptionThe list's description
onQuickLaunchtrue to show it in the site's navigation
noCrawltrue to keep it out of search results
versionLimitHow many versions of each item to keep
validationFormula, validationMessageThe list's validation rule, or empty
hideTitletrue to hide the Title column, as Part 2 did for Departments and OvertimeEntries
uniqueTitletrue to make Title unique, as for the Settings list's setting names
columnsOne entry per column: name, its internal name, and schemaXml, its definition

Here's the Settings list, the shortest:

A code window titled List definitions → the Settings list, showing the JSON object for Settings: title Settings, url Lists/Settings, template 100, its description, onQuickLaunch false, noCrawl false, versionLimit 50, empty validation, hideTitle false, uniqueTitle true, and one column, Value, with its Field element

List definitions → the Settings list
{
"title": "Settings",
"url": "Lists/Settings",
"template": 100,
"description": "Settings for the Overtime Timesheet app, such as the IDs of the payroll and admins groups. Only site owners can change them.",
"onQuickLaunch": false,
"noCrawl": false,
"versionLimit": 50,
"validationFormula": "",
"validationMessage": "",
"hideTitle": false,
"uniqueTitle": true,
"columns": [
{
"name": "Value",
"schemaXml": "<Field Type='Text' Name='Value' StaticName='Value' DisplayName='Value' Description='The setting&apos;s value, such as the Object ID of a Microsoft Entra group.' Required='TRUE' MaxLength='255' />"
}
]
}

Each schemaXml is a column's Field element, the XML SharePoint uses to define a column. It uses single quotes, because it sits inside a JSON string, and &apos; for an apostrophe. Part 2's columns needed these kinds, each with a guide of its own:

ColumnWhat its XML needsGuide
Department in DepartmentsIndexed='TRUE' EnforceUniqueValues='TRUE'Unique values with the REST API
ApproversType='UserMulti', Mult='TRUE', UserSelectionMode='PeopleOnly'A person column with the REST API
BreakMinutes, HoursMin, Max and DecimalsA number range with the REST API
WorkDateFormat='DateOnly'A date-only column with the REST API
StatusType='Choice' with CHOICES and a DefaultCreateFieldAsXml

To copy a column's definition from a list that already has it, read its SchemaXml in the browser (How to See a SharePoint Column's Internal Name and SchemaXml in the Browser). OvertimeEntries also carries Part 2's validation rule. In JSON, its validationFormula is =AND(EndTime>StartTime,EndTime-StartTime<=1,BreakMinutes<(EndTime-StartTime)*1440).

The complete input, pasted into List definitions → Inputs:

List definitions → Inputs
[
{
"title": "Departments",
"url": "Lists/Departments",
"template": 100,
"description": "Departments and their overtime approvers. Used by the Overtime Timesheet app.",
"onQuickLaunch": true,
"noCrawl": false,
"versionLimit": 50,
"validationFormula": "",
"validationMessage": "",
"hideTitle": true,
"uniqueTitle": false,
"columns": [
{
"name": "Department",
"schemaXml": "<Field Type='Text' Name='Department' StaticName='Department' DisplayName='Department' Description='The department&apos;s name, such as Radiology. Each department can appear only once.' Required='TRUE' MaxLength='255' Indexed='TRUE' EnforceUniqueValues='TRUE' />"
},
{
"name": "Approvers",
"schemaXml": "<Field Type='UserMulti' Name='Approvers' StaticName='Approvers' DisplayName='Approvers' Description='The people who approve overtime for this department.' Required='TRUE' List='UserInfo' Mult='TRUE' UserSelectionMode='PeopleOnly' UserSelectionScope='0' />"
},
{
"name": "IsActive",
"schemaXml": "<Field Type='Boolean' Name='IsActive' StaticName='IsActive' DisplayName='IsActive' Description='Yes: staff can choose this department. No: retired, and kept for history.' Required='TRUE'><Default>1</Default></Field>"
}
]
},
{
"title": "OvertimeEntries",
"url": "Lists/OvertimeEntries",
"template": 100,
"description": "Overtime entries: one item per shift worked. Written by the Overtime Timesheet app.",
"onQuickLaunch": true,
"noCrawl": true,
"versionLimit": 50,
"validationFormula": "=AND(EndTime>StartTime,EndTime-StartTime<=1,BreakMinutes<(EndTime-StartTime)*1440)",
"validationMessage": "The finish must be after the start and no more than 24 hours later, and the break must be shorter than the shift.",
"hideTitle": true,
"uniqueTitle": false,
"columns": [
{
"name": "WorkDate",
"schemaXml": "<Field Type='DateTime' Name='WorkDate' StaticName='WorkDate' DisplayName='WorkDate' Description='The day the shift started.' Required='TRUE' Format='DateOnly' FriendlyDisplayFormat='Disabled' />"
},
{
"name": "StartTime",
"schemaXml": "<Field Type='DateTime' Name='StartTime' StaticName='StartTime' DisplayName='StartTime' Description='When the shift started.' Required='TRUE' Format='DateTime' FriendlyDisplayFormat='Disabled' />"
},
{
"name": "EndTime",
"schemaXml": "<Field Type='DateTime' Name='EndTime' StaticName='EndTime' DisplayName='EndTime' Description='When the shift finished. Can be the next day for a night shift.' Required='TRUE' Format='DateTime' FriendlyDisplayFormat='Disabled' />"
},
{
"name": "BreakMinutes",
"schemaXml": "<Field Type='Number' Name='BreakMinutes' StaticName='BreakMinutes' DisplayName='BreakMinutes' Description='The unpaid break during the shift, in minutes.' Required='TRUE' Decimals='0' Min='0'><Default>0</Default></Field>"
},
{
"name": "Hours",
"schemaXml": "<Field Type='Number' Name='Hours' StaticName='Hours' DisplayName='Hours' Description='Hours worked: the time from start to finish, minus the break. Worked out by the app.' Required='TRUE' Decimals='2' Min='0' Max='24' />"
},
{
"name": "DepartmentId",
"schemaXml": "<Field Type='Number' Name='DepartmentId' StaticName='DepartmentId' DisplayName='DepartmentId' Description='The ID of the department&apos;s item in the Departments list.' Required='TRUE' Decimals='0' CommaSeparator='FALSE' />"
},
{
"name": "Department",
"schemaXml": "<Field Type='Text' Name='Department' StaticName='Department' DisplayName='Department' Description='The department&apos;s name when the entry was saved.' Required='TRUE' MaxLength='255' />"
},
{
"name": "Reason",
"schemaXml": "<Field Type='Note' Name='Reason' StaticName='Reason' DisplayName='Reason' Description='Why the overtime was needed.' Required='TRUE' RichText='FALSE' />"
},
{
"name": "EmployeeName",
"schemaXml": "<Field Type='Text' Name='EmployeeName' StaticName='EmployeeName' DisplayName='EmployeeName' Description='The name of the person who worked the shift, when the entry was saved.' Required='TRUE' MaxLength='255' />"
},
{
"name": "EmployeeEmail",
"schemaXml": "<Field Type='Text' Name='EmployeeEmail' StaticName='EmployeeEmail' DisplayName='EmployeeEmail' Description='Their email address when the entry was saved. Empty only for imported entries of people who have left.' MaxLength='255' Indexed='TRUE' />"
},
{
"name": "Status",
"schemaXml": "<Field Type='Choice' Name='Status' StaticName='Status' DisplayName='Status' Description='Pending until an approver approves or rejects the entry. Set by the approval flow.' Required='TRUE' Format='Dropdown' FillInChoice='FALSE' Indexed='TRUE'><CHOICES><CHOICE>Pending</CHOICE><CHOICE>Approved</CHOICE><CHOICE>Rejected</CHOICE></CHOICES><Default>Pending</Default></Field>"
},
{
"name": "ApproverComment",
"schemaXml": "<Field Type='Note' Name='ApproverComment' StaticName='ApproverComment' DisplayName='ApproverComment' Description='The approver&apos;s comment, if they gave one.' RichText='FALSE' />"
},
{
"name": "DecisionBy",
"schemaXml": "<Field Type='Text' Name='DecisionBy' StaticName='DecisionBy' DisplayName='DecisionBy' Description='The name of the approver who approved or rejected the entry.' MaxLength='255' />"
},
{
"name": "DecisionOn",
"schemaXml": "<Field Type='DateTime' Name='DecisionOn' StaticName='DecisionOn' DisplayName='DecisionOn' Description='When the entry was approved or rejected.' Format='DateTime' FriendlyDisplayFormat='Disabled' />"
},
{
"name": "WorkMonth",
"schemaXml": "<Field Type='Text' Name='WorkMonth' StaticName='WorkMonth' DisplayName='WorkMonth' Description='The month the shift started in, as year and month, such as 2026-11. The app and flows filter on it.' Required='TRUE' MaxLength='255' Indexed='TRUE' />"
}
]
},
{
"title": "Settings",
"url": "Lists/Settings",
"template": 100,
"description": "Settings for the Overtime Timesheet app, such as the IDs of the payroll and admins groups. Only site owners can change them.",
"onQuickLaunch": false,
"noCrawl": false,
"versionLimit": 50,
"validationFormula": "",
"validationMessage": "",
"hideTitle": false,
"uniqueTitle": true,
"columns": [
{
"name": "Value",
"schemaXml": "<Field Type='Text' Name='Value' StaticName='Value' DisplayName='Value' Description='The setting&apos;s value, such as the Object ID of a Microsoft Entra group.' Required='TRUE' MaxLength='255' />"
}
]
},
{
"title": "Payroll Exports",
"url": "PayrollExports",
"template": 101,
"description": "Monthly overtime workbooks for payroll. Created by the Overtime Timesheet app.",
"onQuickLaunch": false,
"noCrawl": false,
"versionLimit": 500,
"validationFormula": "",
"validationMessage": "",
"hideTitle": false,
"uniqueTitle": false,
"columns": []
}
]

The List definitions Compose action with Inputs starting with the JSON array: the Departments object with title, url Lists/Departments, template 100, its description, onQuickLaunch true, noCrawl false, versionLimit 50, empty validation, hideTitle true, uniqueTitle false and the first column, Department, with its Field element

Step 6: Check the Site​

Every SharePoint step in the flow uses the trigger's Site URL as its Site Address (Enter custom value, then the Site URL token). The first one, Check the site, asks the site for its title and its address on the server:

FieldValue
Site AddressSite URL
MethodGET
Uri_api/web?$select=Title,ServerRelativeUrl
HeadersAccept: application/json;odata=nometadata

The Check the site action with Site Address set to the Site URL token, Method GET, Uri _api/web?$select=Title,ServerRelativeUrl and the Accept header application/json;odata=nometadata

If the address is wrong, this request fails, and the steps after it don't run, so nothing is created on a site nobody meant. Its answer's ServerRelativeUrl, here /sites/OvertimeTimesheetTest, is used again in Step 11.

The first SharePoint action I added picked another solution's SharePoint connection reference instead of this solution's, and so did every new one after it. I switched each to Overtime Timesheet Setup SharePoint with Change connection reference (How to Change an Action's Connection Reference in Power Automate, Fixed: A Flow in a Solution Uses Another Solution's Connection Reference in Power Automate).

Step 7: Create Each List Only When It's Missing​

Add an Apply to each, For each list, over the Outputs of List definitions (How to Loop Through an Array with Apply to Each in Power Automate):

The For each list action with Select an output from previous steps set to the Outputs token of List definitions

Inside it, every value of the current list comes from items() (How to Use the items() Function in Power Automate), such as items('For_each_list')?['title']. After a reload, the designer shows these as tokens named after the property, such as title.

Find the list looks for a list with that title (How to Check If a SharePoint List Exists in Power Automate):

Find the list → Uri
_api/web/lists?$filter=Title eq '@{items('For_each_list')?['title']}'&$select=Id

The Find the list action with Method GET, the Uri _api/web/lists?$filter=Title eq '…'&$select=Id with an items(...) expression for the title, and the Accept header

If the list is missing is a condition (How to Add a Condition in Power Automate) that compares this expression with true (How to Check If an Array Is Empty in Power Automate):

If the list is missing → left value
empty(body('Find_the_list')?['value'])

The If the list is missing condition with empty(...) is equal to true in its first row, and an empty second row below it

The empty second row is the designer's spare row: the condition's Code view shows only the one comparison.

In its True branch, Create the list sends the list's title, address and template to _api/web/lists/add (How to Create a SharePoint Document Library with the REST API in Power Automate). The same request makes both the lists and the library, and gives each the address from its definition:

FieldValue
MethodPOST
Uri_api/web/lists/add
HeadersAccept: application/json;odata=nometadata
Content-Type: application/json;odata=verbose
Create the list → Body
{
"parameters": {
"__metadata": { "type": "SP.ListCreationInformation" },
"Title": "@{items('For_each_list')?['title']}",
"Url": "@{items('For_each_list')?['url']}",
"TemplateType": @{items('For_each_list')?['template']}
}
}

The Create the list action with Method POST, Uri _api/web/lists/add, the Accept and Content-Type headers, and the Body with parameters, __metadata type SP.ListCreationInformation, and Title, Url and TemplateType each set to an items(...) expression

TemplateType has no quotes, because the template is a number.

Step 8: Hide or Protect the Title Column​

Every list starts with a Title column, and the definitions say what to do with it.

If Title should be hidden compares items('For_each_list')?['hideTitle'] with true. Departments and OvertimeEntries don't use Title, so its True branch does what Part 2 did by hand (How to Hide the Title Column of a SharePoint List with the REST API). Every Uri starts with the current list:

The start of every Uri in this branch
_api/web/lists/getbytitle('@{items('For_each_list')?['title']}')
ActionMethodThe Uri goes on with
Make Title optionalPOST, as a MERGE/fields/getbyinternalnameortitle('Title')
Hide Title in new formsPOST/fields/getbyinternalnameortitle('Title')/setshowinnewform(false)
Hide Title in edit formsPOST/fields/getbyinternalnameortitle('Title')/setshowineditform(false)
Hide Title in display formsPOST/fields/getbyinternalnameortitle('Title')/setshowindisplayform(false)
Find Title in the viewGET/defaultview/viewfields
Remove Title from the viewPOST/defaultview/viewfields/removeviewfield('LinkTitle')

Make Title optional has the headers IF-MATCH: * and X-HTTP-Method: MERGE, and the body { "__metadata": { "type": "SP.Field" }, "Required": false }:

The Make Title optional action with Method POST, the Uri ending in fields/getbyinternalnameortitle('Title'), the headers Accept, Content-Type, IF-MATCH * and X-HTTP-Method MERGE, and the Body with __metadata type SP.Field and Required false

Remove Title from the view sits in the True branch of If Title is in the view, which compares this with true:

If Title is in the view → left value
contains(body('Find_Title_in_the_view')?['Items'], 'LinkTitle')

On a second run, LinkTitle is no longer in the view, and removing it again would fail (Fixed: "Invalid Field Name" BadGateway When Removing a Column from a SharePoint View). The check keeps the step from running then (How to Check If an Array Contains a Value in Power Automate).

If Title should be unique compares items('For_each_list')?['uniqueTitle'] with true. In the Settings list, Title holds each setting's name, such as PayrollGroupId, so it stays, and it must be unique. Make Title unique is a MERGE on the same column with Indexed and EnforceUniqueValues (How to Enforce Unique Values in a SharePoint Column with the REST API in Power Automate):

The Make Title unique action with Method POST, the Uri ending in getbytitle(' title ')/fields/getbyinternalnameortitle('Title'), the MERGE headers, and the Body with __metadata type SP.Field, Indexed true and EnforceUniqueValues true

Step 9: Add the Columns​

Still inside For each list, add For each column, an Apply to each over the current list's columns:

For each column → Select an output from previous steps
items('For_each_list')?['columns']

Inside it, the same pattern (How to Add a Column to a SharePoint List with CreateFieldAsXml in Power Automate):

  • Find the column: a GET to _api/web/lists/getbytitle('@{items('For_each_list')?['title']}')/fields?$filter=InternalName eq '@{items('For_each_column')?['name']}'&$select=InternalName.
  • If the column is missing: empty(body('Find_the_column')?['value']) is equal to true.
  • Create the column, in its True branch: a POST of the column's XML to createfieldasxml.
Create the column → Body
{
"parameters": {
"__metadata": { "type": "SP.XmlSchemaFieldCreationInformation" },
"SchemaXml": "@{items('For_each_column')?['schemaXml']}",
"Options": 25
}
}

The Create the column action with Method POST, the Uri getbytitle(' title ')/fields/createfieldasxml, the Accept and Content-Type headers, and the Body with SP.XmlSchemaFieldCreationInformation, SchemaXml set to the schemaXml token, and Options 25

Options 25 keeps the internal names from the XML and puts each column in the forms and the default view. The library has no columns of its own, so for Payroll Exports the loop runs no times at all.

Step 10: Apply the List Settings​

The last step in For each list, after For each column, is Update the list settings: a MERGE on the list itself (How to Change SharePoint List Settings with the REST API in Power Automate):

FieldValue
MethodPOST
Uri_api/web/lists/getbytitle('@{items('For_each_list')?['title']}')
HeadersAccept, Content-Type, IF-MATCH: * and X-HTTP-Method: MERGE
Update the list settings → Body
{
"__metadata": { "type": "SP.List" },
"Description": "@{items('For_each_list')?['description']}",
"EnableAttachments": false,
"EnableVersioning": true,
"MajorVersionLimit": @{items('For_each_list')?['versionLimit']},
"OnQuickLaunch": @{if(items('For_each_list')?['onQuickLaunch'], 'true', 'false')},
"NoCrawl": @{if(items('For_each_list')?['noCrawl'], 'true', 'false')},
"ValidationFormula": "@{items('For_each_list')?['validationFormula']}",
"ValidationMessage": "@{items('For_each_list')?['validationMessage']}"
}

The Update the list settings action with Method POST, the Uri getbytitle(' title '), the MERGE headers, and the Body with SP.List, Description from the description token, EnableAttachments false, EnableVersioning true, MajorVersionLimit from versionLimit, OnQuickLaunch and NoCrawl from if(...) expressions, and ValidationFormula and ValidationMessage from their tokens

This step runs on every run: it doesn't create anything, it sets the same values again.

Step 11: Add the Settings Items and the Setup Folder​

After For each list, at the top level of the flow, add a Compose called Settings items. It pairs each setting's name with the value typed at the start:

Settings items → Inputs
[
{
"title": "PayrollGroupId",
"value": "@{triggerBody()?['text_1']}"
},
{
"title": "AdminsGroupId",
"value": "@{triggerBody()?['text_2']}"
}
]

The Settings items Compose with Inputs: an array of two objects, PayrollGroupId with the Payroll group ID token as its value, and AdminsGroupId with the Admins group ID token

The names are the ones the app reads in Part 5 (How to Store App Settings in a SharePoint List for Power Apps).

Then For each setting, over outputs('Settings_items'), with the pattern from How to Add an Item to a SharePoint List with the REST API in Power Automate:

  • Find the setting: a GET to _api/web/lists/getbytitle('Settings')/items?$filter=Title eq '@{items('For_each_setting')?['title']}'&$select=Id.
  • If the setting is missing: empty(body('Find_the_setting')?['value']) is equal to true.
  • Add the setting, in its True branch: a POST to _api/web/lists/getbytitle('Settings')/items.
Add the setting → Body
{
"__metadata": { "type": "SP.Data.SettingsListItem" },
"Title": "@{items('For_each_setting')?['title']}",
"Value": "@{items('For_each_setting')?['value']}"
}

The Add the setting action with Method POST, Uri _api/web/lists/getbytitle('Settings')/items, the Accept and Content-Type headers, and the Body with __metadata type SP.Data.SettingsListItem, Title from the title token and Value from the value token

The item type is written out here, SP.Data.SettingsListItem, because this flow always creates the list at Lists/Settings. I read it from the app's own Settings list first, with the request in the guide, and the POST to the test site's list succeeded with it.

Last comes the library's Setup folder, where Part 13 keeps the payroll workbook's template (How to Create a Folder in a SharePoint Library with the REST API in Power Automate):

  • Find the Setup folder: a GET to _api/web/lists/getbytitle('Payroll Exports')/rootfolder/folders?$filter=Name eq 'Setup'&$select=Name.
  • If the Setup folder is missing: empty(body('Find_the_Setup_folder')?['value']) is equal to true.
  • Create the Setup folder, in its True branch: a POST to _api/web/folders, with the folder's address built from Check the site's answer.
Create the Setup folder → Body
{
"__metadata": { "type": "SP.Folder" },
"ServerRelativeUrl": "@{body('Check_the_site')?['ServerRelativeUrl']}/PayrollExports/Setup"
}

The Create the Setup folder action with Method POST, Uri _api/web/folders, the Accept and Content-Type headers, and the Body with __metadata type SP.Folder and ServerRelativeUrl made of the ServerRelativeUrl token from Check the site followed by /PayrollExports/Setup

Step 12: Run It on the Empty Test Site​

In a solution, the new designer saves a draft with Save draft, and its Test asks to Publish & Test, so testing publishes the flow (How to Save a Draft and Publish a Flow in Power Automate). The run panel listed the flow's SharePoint connection reference under Sign in. I selected Continue, typed the test site's address in Site URL, and selected Run flow (How to Test a Cloud Flow Manually in Power Automate). The panel then said No additional information is needed for this step and Not connected., which doesn't mean the run failed (Fixed: "No Additional Information Is Needed for This Step" and "Not Connected").

I built the flow in three stages and ran it after each:

Run (UK time)What the flow hadTookWhat it did
06:22Steps 5 to 75 sCreated the three lists and the library
06:48Steps 8 to 10 as well16 sHid or protected Title, added the 19 columns, applied the settings
07:03Everything16 sAdded the two settings items and the Setup folder

Nothing read the group IDs until the last stage, so the first two runs got a placeholder, not-used-yet, in both boxes. For the third run, I copied each group's Object ID in Microsoft Entra with Copy object ID to clipboard (How to Find a Group's Object ID in Microsoft Entra) and pasted it into the run form.

The test site's Site contents now has the three lists and the library, and Departments and OvertimeEntries are in the site's navigation:

Site contents of the Overtime Timesheet Test site, now listing Payroll Exports as a document library with 1 item, and Departments, OvertimeEntries and Settings as lists, with Departments and OvertimeEntries also in the site's navigation

Departments → New shows its three columns with their descriptions, Title gone, and IsActive ticked by default. I closed the form without saving:

The New item form of Departments with Department, required, The department's name, such as Radiology. Each department can appear only once.; Approvers, required, with a name or email box; and IsActive, required and ticked Yes

OvertimeEntries → List settings → Validation settings has the rule and its message. SharePoint shows the formula without the square brackets that Part 2 typed, the way it came from the flow. I left the page with Cancel:

The Validation Settings page of OvertimeEntries with the flow's formula in the Formula box, written without square brackets, and the User Message The finish must be after the start and no more than 24 hours later, and the break must be shorter than the shift.

The Settings list has the two items. The values in the picture are hidden; they're the same two IDs as in the app's own Settings list:

The Settings list with two items, PayrollGroupId and AdminsGroupId, each with a Value hidden as 00000000-0000-0000-0000-000000000000

And Payroll Exports has its Setup folder:

The Payroll Exports library with one folder, Setup, modified by Admin User

Step 13: Run It Again​

A setup flow has to survive being run twice, because someone will run it twice. I repeated the 07:03 run with Test > Automatically > With a recently used trigger, which reuses that run's inputs (How to Rerun a Cloud Flow with the Same Inputs in Power Automate). The newest run in that list still said Test Running, although it had finished; I selected it anyway, and the repeat used its inputs.

Every check found what the first runs had made. Create the list was skipped for each list:

The repeat run with green ticks down to For each list, 14s, showing list 1 of 4, where Find the list and If the list is missing succeeded and Create the list in the True branch shows a grey skipped sign

So were Add the setting and Create the Setup folder:

The end of the repeat run: For each setting, 1 of 2, with Find the setting and If the setting is missing succeeded and Add the setting skipped; then Find the Setup folder and If the Setup folder is missing succeeded, with Create the Setup folder skipped

Afterwards, the site had the same lists, columns, items and folders as before: 3 columns in Departments, 15 in OvertimeEntries, 1 in Settings, two settings items and one Setup folder. The flow's run history shows all four runs:

The flow's 28-day run history with four runs on Nov 25, at 07:05 AM, 07:03 AM, 06:48 AM and 06:22 AM, taking 00:00:16, 00:00:16, 00:00:16 and 00:00:05, all Test succeeded

Step 14: Compare with the Lists from Part 2​

I compared the test site's lists with the app's own lists, list setting by list setting and column by column, through the REST API:

WhatResult
Departments and Payroll ExportsThe same
Every column of every listThe same type, required setting, index, uniqueness, minimum and maximum, default and decimals; Approvers takes people only on both
OvertimeEntriesThe same, except for content approval and read and edit only their own items, plus the approval status column in the view: Part 3's settings, which Part 19 adds
SettingsThe same, except that the app's own list still allows attachments; the flow turns them off, because nothing attaches files to settings

The flow reproduces everything Part 2 built. The site's permissions are next.

The Problems I Hit​

  • The site template window showed names instead of labels, such as TemplateSelectionTitle. Closing it and reloading the page fixed it (Fixed: SharePoint Shows TemplateSelectionTitle Instead of Select a Site Template).
  • Every new SharePoint action picked another solution's connection reference. I changed each one, as in Step 6.
  • The run panel said Not connected. after a run had started. The run itself was fine.
  • The repeat's run list said Test Running for a finished run. Selecting it still repeated its inputs.

Common Mistakes​

MistakeWhat happensDo this instead
Testing on the app's real siteThe flow changes the real lists' settingsTest on an empty site of its own
Leaving the app's solution as the preferred oneThe new flow is added to both solutionsTick Set as your preferred solution for the setup solution
Keeping another solution's connection reference on an actionThe solution depends on a reference it doesn't includeChange each action to this solution's reference
Inserting a true-or-false value straight into a JSON bodyTrue or False isn't valid JSONUse if(…, 'true', 'false')
Setting the validation before the columns existThe formula names columns that aren't thereApply the settings after For each column
Changing a column's Name in schemaXmlThe app looks for the internal name it was built withKeep each Name exactly as in the definitions
Creating without looking firstA second run fails or makes duplicatesFind, then create only when missing

Troubleshooting​

SymptomLikely causeFix
Check the site failsThe Site URL is wrong, or the connection's account can't open the siteCopy the address from the browser and check the account's access
Create the list fails with 403The account can't create lists on the siteMake it a site owner, or use another connection
Create the column failsAn apostrophe or a quote in schemaXml isn't escapedUse &apos; and single quotes
Update the list settings fails with an invalid JSON messageA true-or-false value went in without if()Wrap it in if(…, 'true', 'false')
Remove Title from the view fails on a rerunThe check before it is missingKeep If Title is in the view
The app doesn't see the groupsThe settings items have other namesKeep PayrollGroupId and AdminsGroupId

FAQ​

Can I run it on the site from Part 2?​

It's built for an empty site, and I ran it only on the test site. On the Part 2 site, every check would find its list, column, item or folder and skip it. Update the list settings would still run, and it would turn off attachments on that site's Settings list.

Does it add any data?​

Only the two settings items, the group IDs typed at the start. Departments and OvertimeEntries start empty. The Setup folder starts empty too; the payroll template from Part 13 goes into it when you install the app.

How do I add a column later?​

Add an entry to the list's columns in List definitions and run the flow again. The new column is created, every other check finds its work already done, and the list settings are set again to the same values.

How long does it take?​

Five seconds for the lists alone on the first run, and 16 seconds for the whole flow, on the test site.

Why doesn't it set the regional settings too?​

The locale and time zone belong to the organization installing the app, not to the app. They're three choices on one page, set by hand in Step 1.

Conclusion​

The Set Up Overtime Timesheet flow, in its own Overtime Timesheet Setup solution, now creates everything the app needs on a SharePoint site:

  • the Departments, OvertimeEntries and Settings lists and the Payroll Exports library, at the addresses the app expects;
  • every column, from one JSON description, with its type, rules and description;
  • each list's settings, including the hidden Title, versions, navigation, search and validation;
  • the two group IDs in Settings, and the Setup folder in the library.

Each step looks before it creates, so a second run changes nothing. Part 19 adds Part 3's permissions to the same flow: the permission level, the groups, unique permissions, item-level permissions and content approval.

Additional Resources​

← Previous: Part 17: Manage Joiners, Movers and Leavers Next → Part 19: Set SharePoint Permissions from the Setup Flow (coming soon)