Two identical Post-its

Copy Power Apps SharePoint Form from one site/tenant to another

0 Shares
0
0
0

Intro

I’ve found myself many times wondering how I can copy Power Apps SharePoint forms from one site/tenant to another and Microsoft does not offer something like this out of the box. After a while, I’ve found a great solution by Denis Molodtsov that helped achieve this with PowerShell scripts. It does not only import SharePoint forms, but also Power Apps (not linked to forms) and adjusts all its sources on-the-fly. How great, right?

Limitations

Although this solution works great, it has its limitations.

If you are using this script together with solutions, you won’t be able to import it. However, as long as you stick to the – let’s say – standard procedures and simply use it to import one Power Apps at a time (whether this is a SharePoint form or not), you’ll be fine.

If you’re interested why that is, feel free to read on. Otherwise, skip to the next heading.

Alright, for all the nerds out there here’s some explanation on why you won’t be able to use it in solutions:

When a solution file is being exported, the included Power Apps .zip files will be zipped “specially”. I don’t know yet what “specially” means, but somehow there is a flag, a setting, or anything in between that makes this solution .zip file special. The script by Denis Molodtsov is simply opening all the files there are in a Power Apps zip, modifying them, and putting them together again into a zip file. Since there is no way (yet) to know what special .zip setting has been set by default solution .zip files, the script will just create an ordinary one. Once the solution is being imported, the import wizard realizes that and throws an error.

Enough nerd stuff for now, let’s read on…

Copy Power Apps SharePoint Form – How it works

There are four steps to copy a SharePoint Power Apps Form from one site collection/tenant to another:

  1. Export the SharePoint Power Apps form
  2. Modify the exported Power Apps form
  3. Import the modified Power Apps form
  4. Publish it

Luckily, this is easier than it sounds ;-). The solution includes a bunch of scripts. Don’t worry though, you just need to execute one of them. The rest is automated.

The scripts have been created by Denis Molodtsov. I don’t take credit for it whatsoever. If you’d like to thank him, I’m sure he’d be happy about it.

The tool needs to have your Power Apps .zip file in a predefined folder (more to that below). It will then unzip it, go through your Power Apps files within that zip, modify all its sources (in case there are sources to modify), will zip it back together, and place it in another folder. This newly created .zip file can then be used to be imported.

Step 1 – Export the SharePoint Power Apps form

This process works for lists as well as for libraries. For this example, I’m just going to use a list.

  1. Go to the SharePoint list the Power Apps form is associated with. On the top right corner, click on the gear icon and select List settings.
  2. Click on Form settings
    You should see the second option to be selected
Copy Power Apps SharePoint Form - Use a custom form created in PowerApps selected
  1. Click on See versions and usage and you’ll be redirected to the Power Apps portal where you can see further details about this form, such as Details, Versions, Connections, etc.
  2. From here on out, you can use the native export feature from Power Apps. Click on Export package at the top
  3. Give your package a name and click on Export
  4. Save it to a location of your choice on your computer. We’re going to need this package for the next step

Step 2 – Modify the exported Power Apps form

For this step to work, the scripts are using the SharePointPnPPowerShellOnline module. If you don’t have it on your device yet, quickly open PowerShell as Admin and install it with the following line:

Install-Module SharePointPnPPowerShellOnline
  1. The first thing to do is to download all the files from the GitHub – FlowPowerAppsMigrator repository. Click on the GitHub link, then on the Code button, and finally on Download ZIP.
Download ZIP in GitHub
  1. Once this is done, export its files to a folder of your choice. You should see something like below now. In my case, I’ve created a folder in C:\GithubRepositories\FlowPowerAppsMigrator.
Path to Repo - Explorer View
  1. Copy your Power Apps .zip you downloaded in the previous step to …\FlowPowerAppsMigrator\src
  2. Once done, under …\FlowPowerAppsMigrator you’ll find a script called RunAllScripts.ps1. Open it in PowerShell (I would open it in ISE or any PowerShell Editor of your choice. Don’t execute it directly… not that it wouldn’t work, but just so you can actually see what is going on. I’m opening it in Visual Studio Code).
    This script just executes 3 other scripts and converts your source URL’s and GUIDs from the .zip package with the destination URL’s and GUIDs
  3. In PowerShell, navigate to the right folder. In my case I’m doing this with:
cd "C:\GithubRepositories\FlowPowerAppsMigrator"
  1. When you’re ready, execute the script. In Visual Studio Code, I’m doing that by clicking on Terminal –> Run Active File
Run Active File in Visual Studio Code
  1. It will then ask you for the source URL. This is the site in which your list / Power Apps SharePoint form is that you would like to export. E.g. https://<your tenant>.sharepoint.com/sites/ExportPowerAppsForm
  2. You’ll then be prompted to login to the source. Do that.
  3. After that, you’ll be asked for the destination URL. E.g. https://<your tenant>.sharepoint.com/sites/ImportPowerAppsForm
    Note: This could be another tenant or simply another site. That’s the great thing about it… it doesn’t matter!
  4. Again, you might be prompted to login (unless it’s the same tenant.. I think it should automatically go through then)
  5. You can see that the script is going through all lists & libraries there are in the source site and replaces them with the ones from the destination. You might see some errors – as long the lists/libraries throwing an error are included in your PowerApps, you can ignore them. Otherwise, dive into that and check what might be the cause. Generally, though, this step hardly fails
Errors that can be ignored
  1. Once it is done, the tool has created a new .zip file in the dist folder. In my case under C:\GithubRepositories\FlowPowerAppsMigrator\dist. This is the file we need to import in Step3

Step 3 – Import the modified Power Apps form

Almost done. In this step, we’re going to import the converted Power Apps SharePoint Form file and upload it.

  1. At first, you would need to make sure that the list you’re trying to import the Power Apps Form to does not have any Power Apps Forms connected to it yet
    1. To check, go to your list that you’d like to import your Power Apps Form to
    2. Click on the gear icon at the top right, then on List Settings
    3. Click then on Form settings
    4. Make sure the first radio button is selected –> Use the default SharePoint form
    5. In case there is a Power Apps Form already associated with the list, a new option under Use a custom form created in PowerApps (requires new list experience) will appear, that says Delete custom form. Click on that and confirm
  2. Go to your Power Apps Portal and click on Apps
  3. At the top, click on Import canvas app
Import canvas app
  1. Click on Upload and select the converted .zip file from the dist folder
  2. Wait for it to be uploaded
  3. Under the Action column, there is a wrench icon. Click on that
  4. In the dropdown under Setup, it says Update. Click on it and select Create as new
  5. Give your form a new name (mandatory!) and click on Save
Create as new selected and name needs to be given
  1. Click on Import
  2. If you did everything correctly, this should now have been successfully migrated and there is only one last step to be done – Publish it

Step 4 – Publish it

Reading through all the steps above it looks like this is a Mammut project, but it actually isn’t THAT bad, right? Or maybe I’m just fooling myself. Anyway, up to the last bit.

  1. Once it has been successfully imported, at the top of the page right under Next steps, click on Open app
Successfully imported. Open app needs to be clicked
  1. Check if all the data sources are pointing to the right location. I would also recommend to quickly click on Refresh on all of them.
    Should there be a data source error, you probably didn’t fix the errors thrown in step 2 -11
  2. Save the app and then click on Publish to SharePoint and confirm. In case there is no Save button available, do a small modification to the app so the Save button will become available

Et voilà! Done. You will now have the Power Apps SharePoint form from your source list copied to your destination list.

Conclusion

Thanks to Denis Molodtsov’s tool we can copy Power Apps SharePoint Forms from one list to another – even between tenants. While this whole process looks rather complicated at first, it isn’t really that hard. And with a little modification, you can easily automate the export-import process from your sites.
Also, there is already an idea submitted for Microsoft to deliver such an option out of the box, but it’s over 2 years old and its status switched from new, to in-progress and back to under review. I even think I saw this feature once on the roadmap, but let’s see.

0 Shares
You May Also Like
styles in a sharepoint list

Power AppsPower Apps Style Guide: 3 Great Ways To Consistently Brand Your Apps

By saving in a data source like SharePoint and then connect it with Power Apps, you can easily have a centralized style library. This ensures that all your apps look consistent and you don't have to go through the hassle and change every element, once you decided to change your primaryAccent color. It makes sense to take your time to sit down, think of the way you'd like your styles to be structured and stay with that through all your app-creations.
Read More
Power Apps Screen in MS Teams

Power AppsPower Apps: Link To Specific Screens & Items in MS Teams

Now with the renaming of Common Data Service to Dataverse and the launch of Dataverse for MS Teams you might be wondering how to create a Power Apps link to specific screens or even to a specific item in your app. The use of parameters for Power Apps has been around for a while now, but when it comes to MS Teams this gets a little more complicated. In this blog post, we're going to check how we can still leverage deep links to Power Apps within MS Teams.
Read More