Hi Everybody,
It's been several months since I posted on the community forums. For my return I decided to share with you an experience on copying a custom Power Apps form from a SharePoint library to another that has the same content type but does not have the same name.
I found a bunch of tutorials on how to copy a form, but all of them refer to copying to a library that has the same name in another site or environment. Maybe a tutorial already exists, but I did not find it. However I still found all my answers in different sources and I compile here the fruits of my research.
The main problem encountered concerns the data source. When you create one in Power Apps, the latter names it using the title of the library. So you have to replace the initial data source in the destination form and it becomes a nightmare when you have a complex form that contains a lot of formulas that refer to the data source.
You can of course modify this reference in each formula manually, which is what I did at first (127 formulas to modify, I might as well tell you that I felt a bit masochistic). After making all the modifications, I had a moment of solitude when I realized that there were still 6 errors linked to a reference to the old data source that I could not modify from the interface: Error in SharePointIntegration.SelectedHidden property
Good news, I finally succeeded! Now let's move on to how I did it, this is a long topic, be lenient if you see spelling mistakes. I tried to illustrate as much as possible. This method works for me, moreover to write the topic I redid the manipulation in order to have the screenshots.
Note: You will need to unzip/zip, DO NOT use the tool integrated into Windows, prefer 7zip (that's the one I use). I don't know why with the Windows one I was systematically confronted with a fairly telling error when opening the imported form: There was error opening the file.
Step 1 - Export source form
- From library/list settings, go to "Form settings"
- Follow "See versions and usage", you'll get in Power Apps.
- Give a name and click "Update" link
- Select "Create as new" and save
- Finally click "Export" button, Power Apps will createing the package and ask you for a download location once done. You'll get a zip file called as you named your package with a time stamp.
Step 2 - Editing package's JSON files
- First unzip archive, you'll get the following items
- Navigate to last sub folder in "Microsft.PowerApps", my path is "Microsft.PowerApps\apps\83342470770660478
- We're going to edit the first JSON file to link form with the new library/list (mine is "8334247077066760478.json").
Note: I use Visual Studio Code, it provides an usefull "Format document" function to get JSON in a more readable way.
Look for the "embeddedApp" object :
We'll need to change "listId" and listUrl" properties. You can get these information in settings page of destination library/list
Note: Get rid of "%7B" and "%7D" which are respectivelly Uri encoded value of "{" and "}", we don't need them.
Once done, save and close file.
- Now, rename the .msapp file into .zip (just add .zip at the end)
Note: To edit files in this archive, I don't unzip, I use 7Zip and edit files from 7Zip manager. I didn't test unziping and zipping back. I'll let you give a try if you prefer that way.
So, I open archive with 7Zip manager and get this
Navigate to "Controls" folder, there are 2 JSON files we'll need to edit
Edit both and replace any occurence of old datasource by new one using CTRL-H. In mine files old one is "Courriers 2024" and new one is "Courriers 2025" which are library's title.
We are done with file editing, close 7zip manager and rename back file to .msapp
- We now need to zip back the package to send to Power Apps. Go back to first folder
Select both file and folder, zip them, destination archive name does not matter
Step 3 - Import our new package into Power Apps
- From Power Apps, Go to "Apps" section and select "Import package" from "From package (.Zip)"
- Once Power Apps is done with upload it brings you to import package configuration page, click "Create as new" link and give it a new name
- We're done with the import, open Apps from resulting page
Step 4 - Manage datasources
- At this stage, Power Apps notifies us that form isn't connected to any data, thats what we're going to fix in this step
- Go to data pane and remove old datasource
- Finally, add the new datasource and all the red crosses disappear.
- Now all you have to do is to save and publish. Once done, go to your library/list, the new custom form will be available and functional.
That's all folks !
_______________________________________________________________________________
If this helps you in any way, please give it a like.