Getting Started
Microsoft’s PowerApps platform is a powerful tool which can enable your business to accomplish many tasks remotely through mobile devices. The ability to create and submit content on the go streamlines many processes, which previously may have been done back at the office. The application allows for fast development and ease of implementation as it integrates with Microsoft’s library of online applications.
Recently one of our clients had a requirement to submit images taken by a mobile device to a SharePoint library. This seemingly simple task, actually appeared quite complicated once I dug into the steps required. I began doing my research on forums, blogs and threads. Just as with any new application, PowerApps is constantly evolving and online support content quickly becomes out-dated and obsolete.
What I Found
I stumbled upon a tutorial video for saving images from PowerApps to SharePoint created by Paul Culmsee’s. Now this video could likely be all that you need to get started; however, there were a few things I learned along the way that might make things a bit easier for you as well. I studied that video many times, followed the instructions exactly, but still could not get my application to work.
Beyond the trial and error I had to undergo to finally get the application working, my requirements were slightly different than just saving images to SharePoint. I needed the photos to be linked to a master record (list item) and then through the application, be able to pull those images from SharePoint back into the app. This is where I had to do a bit more digging.
What You’ll Need
The basic setup required for saving images to SharePoint from PowerApps is…
A SharePoint List to connect PowerApps
A SharePoint library to save the images from PowerApps
A text editor or script editor such as Notepad++
PowerApps mobile application on a mobile device (for testing)
Let’s Begin
I’m only going to cover my requirements gaps and the mistakes I made while following this tutorial video I mentioned earlier. The video covers this process in a great amount of detail so I see no need to go through it all. If you have already seen the video, I’m going to pick up around the editing of the Swagger file.
Editing the Swagger file
Up until the editing of the Swagger file, everything was super easy to follow thanks to Paul Culmsee’s excellent instructions. The file gets created using an online tool called apigee. At this point, you should have created your Flow and copied the HTTP Request action’s URL. That URL contains everything you need to populate the Swagger file.
Personally, when I completed the wizard on apigee and created my Swagger file, all of my parameters were blank. Not sure why, but thanks the to the URL copied from the HTTP Request action, I was able to open the Swagger file up in Notepad ++ and make the updates. Each parameter is called out in the query string, and those values will be used to set the default property of each parameter.
Updating “parameters”
api-version: should be something like “2016-06-01”
sp: should be similar to “/triggers/manual/run”
sv: should probably be “1.0”
sig: is a series of alpha-numeric characters and special characters which will be unique
Updating the “host” property
There have been many threads online regarding the “:443” appended to the host URL when copied from Flow. Users reported failing Swagger files due to authentication issues. The most recent solution for this it to just remove the “:443” from your Swagger file in the “host” property.
Updating “consumes” and “produces”
These two lines of code were probably what took me the longest to figure out. My Swagger file generated the “produces” property and set it to null. While this is correct JSON, it doesn’t work for PowerApps. This property needs to be set to an empty array. Additionally, my Swagger file was missing the “consumes” property which should also be set to an empty array (consumes may not be necessary in all cases).
"consumes": [],
"produces": [],
Adding a Master Record Property to the Swagger file
A SharePoint column will need to be created to store the Master Record ID. The ID can be passed into the HTTP Request using additional parameters in the Swagger file. Properties can be added by copying the format for filename. See the example below:
{
"name": "masterRecordId",
"in": "query",
"type": "string",
"description": "item id of the linked list item",
"required": true
}
Follow the URL – forward slashes
The Swagger file breaks down the URL which was copied from your HTTP Request action in Flow. Each portion of the URL is used in a cascading format down though the various properties in the file. Keep track of the forward slashes, one missed slash will produce errors when trying to use the Swagger file. The full URL is broken down into four (4) properties.
“host”: the root without Hypertext Transfer Protocol
“basePath”: path after first forward slash (include the slash) – typically “/workflows”
“schemes”: Hypertext Transfer Protocol – “http” or “https”
“paths”: the remaining path starting with a forward slash – usually something like this “/randomNumbersAndLetters/triggers/manual/paths/invoke”
Editing the Flow
The Flow outlined in the tutorial video works great for completing the task of saving images to SharePoint. However, there are a couple of steps that I took in order to link the images to my master record in the SharePoint list. Secondly, in order to display those images back in PowerApps, on a mobile device, there are some workarounds required.
Creating a Master Record column
The easiest solution for linking a master record to the images saved to SharePoint, is to create a Single line of text field and name it Master Record ID. The more elegant solution, is to create a Lookup column which allows for metadata to be pulled in from the master record. Either approach works, however, in PowerApps there is currently a delegation issue when using the Filter() function on a Lookup column, so a Single line of text field works great.
Updating the Flow to set the Master Record column
This task is simple, the Flow can be updated to first use the Create file action, then use the Update file properties action to set the Master Record ID. The masterRecordId property in the Swagger file will be the value of that column. The only catch is, if you decided to use a Lookup column, you will need to use the int(…) expression to convert the masterRecordId to an integer.
THE PICTURE COLUMN
This was probably the biggest work-around in the whole implementation. At this time, PowerApps does not support displaying images from a SharePoint library on a mobile device. It will work great while previewing in PowerApps studio, but fails to display the picture while on a mobile device. Why? Well it seems to be due to security and authentication gaps. Microsoft developed a patch of sorts, while you cannot display the “images” you can display a “link” to the image in the form of a Hyperlink/Picture Column.
To get around this issues, create a Hyperlink/Picture Column in your images library. This column will essentially store a link it itself. I’ve seen other solutions online that will roll-up images from SharePoint in a single list, but that adds a third list to your application and can be messy. Just adding the column in the image library itself works best. Format the URL as a Hyperlink, we will come back and change that later.
Updating Flow to set the Hyperlink/Picture column
Once the column is created and formatted as a Hyperlink, the Update file properties action can be used to set the column. The results of a previous Get file properties action will provide the value for the Hyperlink column. Use the dynamic content property named “Link to item”. Once all of the properties are set, update the Flow and close it.
Note: the Hyperlink/Picture column will not appear if the URL is formatted as a Picture. That is why it must be set to Hyperlink first, then later changed back to Picture. The Flow will continue to work after making the change.
Displaying the images in PowerApps
The final step is to retrieve the images saved to SharePoint in PowerApps, when editing a master record (list item). Add the data connection to the images library and Filter() on the Master Record ID column. Then return to the image library in SharePoint, and change the Hyperlink/Picture column to Picture. This will allow the images to display properly once the gallery or image control is linked to the data connection using the Hyperlink/Picture column.
Wrap Up
I hope these additional steps were helpful in implementing your app. These were the biggest hurdles I had to overcome to meet my requirements and if you had similar issues while implementing this solution I hope this saved you some time. Please share your work-arounds or fixes below!
Hi…I see this was recorded awhile ago…Has MS updated powerapps in order to upload the photo without having to go through flow yet?
Hey Steve, not entirely. Although you can check out this blog for a process that doesn’t require as many steps.
https://explore.emtecinc.com/blog/how-to-upload-camera-pictures-directly-to-microsoft-sharepoint-with-powerapps-and-microsoft-flow
You could possibly modify that approach as well to account for looping. I believe that only handles a single upload at a time.
You will want to follow the steps in this blog regarding how to display the images from SharePoint back in PowerApps even with the method linked above.
You can also save images directly to a list item using this approach:
https://www.techmikael.com/2018/03/a-workaround-for-saving-hi-res-photos.html
Hope that helps!
hi,
can you please show me how to filter() on the ID column to get the image back in powerapps ?
Hi Ronald,
Add an Image or Gallery control to your app. Set the “Items” property of the Gallery to the following formula:
Filter('YourSharePointImageLibrary',MasterRecordID=Text(Gallery_Browse.Selected.ID))
The first parameter for the filter is the connection, the second one is the logic. “MasterRecordID” is the column in the image library which contains the related List Item ID. “Gallery_Browse” is the default Gallery on the Browse screen (in my app), that is where users can select list items to view. The Filter() uses the selected list item via “Gallery_Browse.Selected.ID”. This is converted to Text() for the comparison to work properly. That conversion depends on the column type you used, a lookup column may need to be compared using an Int() conversion.
Hi Zach,
I was able to follow the tutorial to send the picture in the SharePoint library using flow while just using one query parameter ( the filename ) but as soon as i add a second query parameter to receive the masterid (of course i update the flow first to be able retrieve it) something weird happens. The flow process keep working well but the image registered in the library is blank or null. Even downloading it doesn’t give me the possibility to see it. It says that the format is not supported. How can I keep it well formatted in the SharePoint library even with multiple query parameters? Did you send your masterid as a query parameter? Could I have your help as soon as possible?
Hey Eddy, double check all your references of fileName and make sure masterRecordId appears in each place as well. Those object properties need to be passed along in the same way. It’s been a while but I believe there are 3 places (PowerApps, Swagger and Flow). It’s possible that the Flow continues but has a null reference for Filename because the object passed in was formatted incorrectly. Postman is the best way to test this stuff out. It’s quick and the best part is it allows you to be sure the problem isn’t with your object or Flow first. Then you can get PowerApps right.
Great solution which works excellent! But be aware that you need Premium to run the solution as a whole. The Request connector requires this.
Hey Mike, yes based on the new licensing structure that was announced this year the solution does require premium. This solution was designed prior to the introduction of premium and at the time was really the only way to achieve this results.
There are some new tutorials on saving multiple documents/images to SharePoint using PowerApps and Flow with the new PowerApps connector for Flow. You can use the same approach with the gallery and data collection in PowerApps, then pass an object converted to a string into Flow variables. No need for complex HTTP requests. Keep in mind, the objects need to be converted to strings using Concatenate functions because currently Flow only supports strings when using the “Ask in PowerApps” feature.
Upload Multiple using the attachment control:
https://www.youtube.com/watch?v=UYK7yruBHDM
Upload multiple using the image control:
https://www.youtube.com/watch?v=5XsWgVnR7SU
[…] Important! This way of working is accompanied by a custom connector that we wrote for PowerApps and Flow to forward this document. How to implement this can be seen in the blog below.https://repointtechnologies.com/saving-images-from-powerapps-to-sharepoint/ […]
Hi Zach,
I am building my first PowerApp, I am an RN looking to prove the solutions in MS 365 can be a great solution for our group. I am not an IT professional. With that said I was able to make it though building the SP list, PA and the Flow. My stopgate is the building the API I was able to work the Postman phase but when I got to Apigee I could not figure out where to start. I am unsure if the app has been updated I cannot get to the same screen you are working on. I am using the free version, does it require to be a paid version? I found a swagger file online but seems like a lot to change and I have never done this before so wanted to reach out to you to see if you could provide any guidance.
Thank you,
Barb
Sorry Barb I know this a very late repy! The process has chnaged quite a bit from this video. Power Apps and Flow make this process much easier now. You can follow the steps in this video to upload files to SharePoint without the swagger files or many of the complexities of this article.
https://www.youtube.com/watch?v=3QaiM8SeWfM
Hi,
I want to create an application for a client, through which the client will upload an Excel file from its Local PC to it’s network drive through PowerApps using File System Action in flow, but I am confused how can I get that file in flow Like I am not storing it in Sharepoint or OneDrive as the client don’t have licenses for Sharepoint and OneDrive.
Any Idea? Please Help!
Same approach with any file type. Follow the steps in this video, but change the SharePoint > Create file action to File System > Create file action in Flow.
https://www.youtube.com/watch?v=3QaiM8SeWfM
Hi Zach,
I want to create a flow for a client that the user will upload a file from its local PC to its Network folder through PowerApps,
the Flow will need File System Action, but I am confused how to build that flow, because I am not storing those files in Sharepoint Document library or OneDrive as the client don’t have licenses of them.
can you please tell me what will be the flow, as the user will select the file from its local PC and the file should be uploaded to a certain folder in it’s network drive.
Help Please
Hey Mustafa,
You can achieve this using a Power Apps Flow trigger and a Parse JSON action in Flow. Your Power App will need to allow users to attach a file and then pass the file to Flow through a JSON object. The format in the Parse JSON object would look like this:
{
"type":"object",
"properties":{
"fileName":{
"type":"string"
},
"fileContent":{
"type":"string"
}
}
}
Here’s a great video outlining the process:
https://www.youtube.com/watch?v=3QaiM8SeWfM
He describes how to use what I just described to save files to SharePoint. But you will want to replace the SharePoint Create File action with the File System > Create File action.