UPLOAD files from Power Apps to SharePoint Document Library ➕ Set Properties

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone Resa here in this video I will show you how to upload files to SharePoint and set the properties of those files in one go from power apps so let's check this video out in [Music] action let's begin with creating a SharePoint document Library I'll pick one of the library templates invoices and use this template to create my document Library here I can upload files and I also have the ability to set the properties associated with this document my library is ready let's see how we can build a power app that allows us to upload files and Associate metadata in make. power apps.com I'll start with the page design and begin with a blank canvas app first I'll go ahead and connect to my SharePoint document Library I'll connect to SharePoint connect to my SharePoint site select my invoices document library and connect to show the data from my document Library I'll insert a gallery control connect this to my invoices library now to upload documents from power apps we do not have a file upload control however we do have an attachments control that we can get if we leverage if form control experience and connected to a SharePoint list so temporarily only to get that attachment control I will go ahead and add another connection to SharePoint and this time connect to a SharePoint list my form control data source will be that SharePoint list and one of the controls here is the attachments control that is a part of the attachments data card so what I can do here is I can copy this control head back to my screen and paste this control the form control the only reason I added it was to get this attachment so I do not need it I will delete it also the association to my SharePoint list I no longer need it so I'll remove it now I have this attachment control I will rename this to attach for the user to upload files I'll add another screen in my app and this attachment control I will cut it from my home screen and paste it in this second screen now this control has a few errors to begin with one of the properties is border color I'll go and remove that for formula tool tip remove the formula do the same for every property that is erroring out this control allows the user to upload multiple files you can Define how many number of files can they attach and what can be that maximum attachment size if I preview and click attach file I can start attaching files to this control you can also attach multiple files remove this also supports drag and drop I'll insert a button I'll set the text of this button to upload and on select of this I would like to go ahead and upload this file to my documents library to do that I will take the help of power aut it I'll click on create new flow click create a flow it leverages the new power apps V2 trigger I'll add an input I will select the type as file so this will allow power apps to call Flow and pass information about a file that I would like to upload to my document library in SharePoint and to do that we have a create file action in SharePoint I'll put my SharePoint site address where this document Library exists for the folder path I'll go to show picker and directly select my document Library called invoices file name and file content for file content we have Dynamic content available from the Trigger action which is file content so I'll select this if you hover over this it will show the expression behind it which is trigger body file and from within it it reads the content bytes for file name all we have to do is copy thisr a contrl c go to file name go to EXP expression paste it the expression begins with at and a curly brace remove it the expression ends with the curly brace remove it this leaves us with trigger body file instead of content bytes I will use name all lowercase I'll click okay I would want power apps to wait for flow to go ahead and create the file I will add another step here respond to a power app action from the power apps connector here I'll add an output of type text I'll say file uploaded yes that completes my flow very important to name the flow upload file to SharePoint and click save this will go ahead and save the flow in power automate plus connect to that flow from my power app now for my upload buttons on Select Property all I have to do here is go ahead and Trigger my flow run as I start typing the name of my flow which was upload file you can see how intelligence guides me through to call the flow you have to call the run method of the flow so I'll use upload file to SharePoint do run I need to pass an input parameter which is an object file and this is expecting a record a record that includes two pieces of information name and content bytes a record is represented by curly braces within this name all lowercase this will be the name of the file I can use attach dot attachments that gives me all the attachments from this attachments control for now we are focused on uploading one file so I'll use the property first to get the first file that's attached dot name comma my second property is content bytes first attach do attachments dot value that completes my file property I'll close it with a curly brace and close my function with a round bracket now let's connect the two screens together screen one here I'll insert a button we call it upload files on select of this button I will navigate the user to my second screen upload takes me to my second screen now whenever I land on the screen I would want to reset the data in the attachments control the screen has an unvisible property here I will use the formula reset the name of my attachment control let's go back to screen one upload files the attachments control starts from a clean slate upload this button should be active only if a file is attached the display mode property of this button if count rows of attach do attachments is greater than zero you set the display mode to edit else you set the display mode to disable so the moment the user uploads a file this button becomes active when upload is clicked we have our formula to call the flow right after this go ahead and take the user back to my previous screen which is my home screen let's go back to the home screen and try the entire scenario out upload files I can attach a document click upload this should go ahead and Trigger my flow the flow should go ahead upload my document I can confirm that by exploring my document Library the file has been uploaded the gallery may show the new record or may not one of the things we can do is insert one of the icon controls called reload please note we want to do a Reload not a refresh I want the G gallery to reinitiate the query to get the documents and to do that when this icon is clicked I will set a variable called where reset to false and then I will set that same variable V reset to true all I'm doing here is changing state of a variable this variable I will use to filter the items of my gallery filter invoices on that variable so now let's go try upload another file the flow gets called this time if I select this it got me the document that was uploaded to allow the user to edit the properties of existing documents next Arrow icon in the gallery when the user user selects this what I can do is take the user to a screen that has a form control and we have templates for that type of screen so I'll simply select the form screen here we have the form control I'll connect this to my invoices document Library this will start bringing in the columns when the user clicks on the accept icon it will submit the data in this form control the form control has a property called item the context of that comes from the gallery on my home screen so here I can simply use the name of my gallery do selected and the form control has an on suuccess property when it successfully submits the data I'll take the user back to the previous screen and that would be my home screen when the next Arrow is clicked in the Galler Galler I will simply navigate the user to my form screen so now if I select I can start setting the properties for that document and submit notice all those properties for my document are set in the library when I am uploading the file I would like to give the ability to the user to define the prop properties for the file what we can do is go and insert the edit form control I'll connected to my same documents Library the default mode of this form I will set to new this form I will rename to form invoice and whenever I visit the screen I was resetting the attachment control I will also ensure that I use the reset form function to reset my form control on the screen so every time I click upload files I will get the option to attach files and also set properties now when upload is clicked I am calling my flow to upload the file but along with that I also want to set its properties so I will go back to my flow by editing the flow directly from the Power app experience itself in the flow trigger I will add an input of type text and I will call this file properties now in SharePoint first you have to create the file and then you can update its properties here we are creating the file next step is I'll add an action called update file properties from from SharePoint connect to my SharePoint site connect to my document Library it's asking for The Unique identifier of the item that we are trying to update that is the item id Dynamic content coming from the create file action and the next step is to update all the properties of the file now in my power app I will simply be passing all the information from that form control now here in my flow I do not want to parse all that data one by one and start plugging it into these different columns so a trick that I will play here is I'll add an action called compose think about this as a static variable here I'll plug in the SharePoint site address and for the update file properties action instead of picking the site address if you scroll right at the bottom there's an option called enter custom value here I will pick the output of compose the site is dynamically being defined ID is set all I need now is item and for item all we have to do is write a very simple expression Json is the function the parameter is Dynamic content from the power apps V2 trigger file properties I'll click okay that completes my updates to the flow I'll click save and I will close the flow which will in turn refresh the connection of that flow in my power app my upload button if if we explore the run method again the first property it is expecting here is text that's the file properties and that information will come from my form control and I want to pass that data in the form of Json so in power apps we have a Json function the first parameter it expects is data that would be my form control. updates and the second parameter is the format I'll use Json format. include binary data I'll put a comma my second parameter is the file parameter no changes there now let's go ahead and test this out go to attach upload a file set its properties now if I click upload this will go ahead and Trigger my flow if I click refresh here is my latest file with its properties if I go to view details I can see all those properties set and if I go to SharePoint here is the latest document that got uploaded and these are all its properties our attachment control already allows multiple files to be uploaded the only change we have to make here is when upload is clicked I'll format the text to make the formula more readable here I will use the function for all on my attachment control. attachments and within this Loop go ahead and call the action to run the flow the form information is set the file information though I'll make a change here I will use this record. name and this record do value this record points to the current running record in the for Loop which is nothing but the attachment all I have to do now is close the for all function let's try it out I'm uploading a couple of files I'll set their statuses to paid vendor is rdte and I'll set their due dates to 29th of Feb and click upload this will begin the process of uploading both those files and setting the metadata I'll reload both my files are here and if I explore this in SharePoint here are those two files and here are those property values that I set and you can build an entire document Library experience in power apps the home screen shows all the documents as well as the folders in my document Library this library of mine has files and folders within this folder there can be subfolders files within them more folders or files so and so forth currently it shows me the files and folders at the top level any of these files I can select I can open the file I can edit the properties of the file here I'll change it status to approved and I also have the option to select a file and delete it if desired I can select a folder and open that specific folder So currently I am in the folder Asia in here I have a file and I have another folder folder so I have full navigation capabilities available here in the document Library experience plus I have the ability to upload files same logic as before set its properties click upload the flow gets called and my table control here shows the newly added files with their properties is set if you enjoyed this video then do like comment and subscribe to my YouTube channel and thank you so much for watching
Info
Channel: Reza Dorrani
Views: 44,289
Rating: undefined out of 5
Keywords: powerapps upload file to sharepoint document library, powerapps upload file, power apps, powerapps upload multiple files to sharepoint, powerapps, powerapps upload, powerapps add file, powerapps save file to sharepoint, powerapps v2 power automate, reza dorrani, upload and tag multiple files from powerapps, learn powerapps, powerapps upload images and files to sharepoint library, sharepoint, upload, file, upload file, powerapps v2 trigger, powerapps v2 file content, document library
Id: QUwzvUXgj58
Channel Id: undefined
Length: 21min 37sec (1297 seconds)
Published: Mon Feb 19 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.