Power Platform Solutions make deploying CDS (now known as Dataflex Pro) based Power Apps and their underlying/related assets a breeze. But what if you want to package and deploy a Power App which uses SharePoint as a data source? In this article, I’m going to outline two approaches to help you package and deploy your SharePoint-based Power Apps.

Approach 1 – Power Automate

This is my preferred method because it is the easiest for the citizen developer audience to deploy. The Power Automate approach is something that I learned from the wonderful Audrie Gordon. She used it to deploy the SharePoint lists for the Crisis Communication Power Apps template.

For this approach, you can create a Instant Flow in Power Automate which contains a series of SharePoint HTTP which make SharePoint REST API calls to build out your lists and libraries. This Instant Flow can be kicked off manually and ran to deploy the lists in the location of your choice.

Creating a List

The first step is to create the list. This can be done by inserting a SharePoint HTTP Request Action in your Flow and setting it up like so:

Figure 1 – Create List Action in Power Automate

You’ll want to update the Title and Description properties and fill those in with the name and description of your list. The “BaseTemplate” property is what determines the type of list you’re creating. 100 is a blank list and 101 is a document library.

Creating Fields in the List

Once you create the list you need to add additional SharePoint HTTP Actions to create each field that you need to add in the list. That action will look like this:

Figure 2 – Create Field Action in Power Automate

In the URI input you’ll want to make sure you replace the “getbytitle(‘Name of your list’) with the name of the list you want to add your field to. The body of the action will vary based on the type of field you want to create. For quick reference, I have provided a table with the most common column types and the associated body code needed for the Power Automate action below:

Column Type Power Automate Code
Single Line of Text {
‘__metadata’: {‘type’:’SP.FieldText’, ‘addToDefaultView’: ‘true’ },
‘FieldTypeKind’: 2,
‘Title’: ‘Name of Single Line of Text Field’
}
Multi Line of Text {
‘__metadata’: {‘type’:’SP.Field’, ‘addToDefaultView’: ‘true’ },
‘FieldTypeKind’: 3,
‘Title’: ‘Name of Multi Line of Text Field’
}
DateTime {
‘__metadata’: {‘type’:’SP.FieldDateTime’, ‘addToDefaultView’: ‘true’ },
‘FieldTypeKind’: 4,
‘Title’: ‘Name of DateTime Field’,
‘DisplayFormat’: 0
}
Boolean (Yes/No) {
‘__metadata’: {‘type’:’SP.Field’, ‘addToDefaultView’: ‘true’ },
‘FieldTypeKind’: 8,
‘Title’: ‘Name of Yes No Field’
}
Choice { ‘__metadata’:
{ ‘type’: ‘SP.FieldChoice’, ‘addToDefaultView’: ‘true’ },
‘Title’: ‘Name of Choice Field’,
‘FieldTypeKind’: 6,
‘Required’: ‘true’,
‘Choices’: { ‘results’: [‘Choice 1’, ‘Choice 2’, ‘Choice 3’ ] }
}
Hyperlink {
‘__metadata’: {‘type’:’SP.Field’, ‘addToDefaultView’: ‘true’ },
‘FieldTypeKind’: 11,
‘Title’: ‘Name of Hyperlink Field’
}
Number {
‘__metadata’: {‘type’:’SP.FieldNumber’},
‘FieldTypeKind’: 1,
‘Title’: ‘Name of Number Field’
}
Person/Group {
‘__metadata’: {‘type’:’SP.Field’, ‘addToDefaultView’: ‘true’ },
‘FieldTypeKind’: 20,
‘Title’: ‘Name of Person or Group Field’
}

Figure 3 – SharePoint REST API Column Types

Add the Columns to the Default View

This next step is optional. If you want to make sure that the fields you just created show up in the default view of the list then you need to perform a couple more actions in your Flow. First, you’ll need an initialize variable action which will store an array of all of the column names you want to add like so:

Figure 4 – Configure the Column Names Variable

Once you have that, you need an Apply to Each action and within that you’ll make one final SharePoint HTTP action which will take those columns and add them to the default view like so:

Figure 5 – Add the Columns to the View

Approach 2 – PowerShell

If you’re comfortable with PowerShell then you can leverage PnP PowerShell to save your lists as templates and deploy them. Jaoa Ferreria has already written a detail blog post on how to do this so rather than re-invent the wheel, I’ll just post a reference to his blog so you can learn more: https://sharepoint.handsontek.net/2019/09/15/save-a-modern-sharepoint-list-as-a-template/

Wrapping Up

The combination of either of the methods outlined above, with Power Apps and Power Automate’s built in export/import functionality will allow you to easily deploy your SharePoint-based Power Apps. After you deploy your lists and Power App into the new environment, you will still need to update the data connections in Power Apps to the new locations.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.