Upload files to Dataverse from Power Apps | Patch multiple files | File Column tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video I will show you how you can work with dataverse table file column type in powerapps I will showcase how to use the patch function to upload files to the file column leverage the attachments control to upload multiple files download files View files and a lot more so let's check it out in action foreign [Music] in database tables we can create a column of type file columns store binary data and this column will allow you to store a single file picture text or attachment the maximum file size by default is 32 Max and this can be increased to a maximum of 10 gigs now let's create a table in dataverse and leverage the file column I'll create a table called contract in this table I can add my columns in this case I'll keep it simple I'll just take the name of the contract and the date of type date only and to allow the user to attach a file I will create a new column I will call this contract document the data type I'll pick file I will keep the max file size as the default 32 MB and I will click save the moment you create this file type column if you head over to relationships you will notice that there is a relationship that immediately gets created with a table called as file attachment and this is a many is to one relationship now let's create an app and let's look at how a user can create a record and attach a file one of the options to create an app is a model driven app and we can create that app directly from the dataverse table experience itself I would want that contract document file to be a part of the main form so for that I will head over to forms pick the main form and I will add the contract document column and the contract date column I will click on publish I will get back to the contracts table and click create an app I will give my app a name and click create this will create a model driven app based on my datawverse table and if I was to play this app I can create a new record I will give my contract a name pick the contract date now notice it says this record hasn't been created yet so in order for me to enable this file control experience I have to first save this record and immediately then I will have the option here to go ahead and attach a file so I'll attach a file if I click on it it will download that attachment I can delete and upload another file but at a time I can only and only work with one file for a file column for a specific record if I need to attach additional files here I will have to create additional file columns later on in the video I will show how to add that ability to have multiple attachments now this was from a model driven app perspective let's try the same experience for a canvas PowerApp in make.powerapps.com under create I will start from a dataverse table I'll add a connection to dataverse pick my contracts table and this will create a standard three screen canvas PowerApp experience if I preview this app here is that record that I created in the table called contract a if I select this it will show me the details of that record this leverages a detailed form experience if I would like to show additional fields from my table I can go to add and add the additional fields so I'll show contract date and I will also show contract document if I preview this app here is my document that I had attached to that file column contract document if I select this it will download that file if I go to edit this will take me to the edit form experience once again I will go and add my Fields contract date and contract document remember only one file per file type column so here I cannot add multiple attachments I have to remove this and then upload a different file and Save and this will now update the attachment for that file column this technique leverages the form control experience and the control that it leverages is the attachments control for this control if you notice maximum attachments is hard coded to one by default purely because the file column only works with one attachment plus if you look at the default property for this data card experience it gets data from the contract document file column and converts it into a form that the attachments control expects the attachments control expects two Key Properties display name which is the name of the file and value which is the file data plus the attachments control expects tabular data and that is the reason why the default property is using the stable function I will create a new screen in here I've added two text labels one for name one for contract date for name I will insert a text input control and then for contract date I will input a date picker control now for the contract document I need that attachments control so from my edit form experience I will select this attachment control copy this Ctrl C go back to the screen and paste Ctrl V to bring that attachment control experience this will lead to a few errors if I had to edit in the formula bar all you have to do is clear the formulas that are erroring out border color items toolter display mode now to submit this contract data I'll add the submit button on select of this I will patch to my data source which is contracts which is already connected in my power app I'm trying to create a new record so I will use defaults function on my contracts table I will patch the name column will be the text box dot text contract date will be the contract date picker control Dot select a date and the contract document now this expects data in a particular format an object that contains two properties file name which is the name of the file and this will come from this attachments control will output tabular data I only need the first one so I can say first attach dot attachments and from here get me the name comma the value first of attached dot attachments Dot value I will close the object close the update property and close the patch function format text and this is what my patch function looks like and once the patch is performed I will navigate the user to my home screen I'll create a new record contract B here I can upload a file I can even drag and drop a file click submit this will now patch my record and the file to my database table if I pick contract B I can see that file that I uploaded there are various scenarios in which you would want to upload multiple files for a specific record for example for my contract management scenario I would like to provide the ability to the user to upload multiple supporting documents what we can take advantage of is the relational nature of dataverse in tables I will create a new table called contract supporting documents and in this table I will create a column called supporting document first type file and I will create another column called contract lookup and create a lookup column to create a relationship with my related table which would be my contract table this relationship which is my lookup column contract lookup is a many-to-one relationship so I can have many files that are related to a single contract record since this is a separate table I can also have metadata associated with those supporting documents that the user uploads in this case I'll keep the scenario simple the name column by default is mandatory so I will edit this and make this optional since in this case I'm purely using this table to upload supporting documents I will head back to my PowerApp and refresh my data source connection because there is a new relationship now that has been formed on the contracts table this is coming from the contract supporting document table now here when I pick a specific contract and let's say I edit this here I would like to give the user the opportunity to upload multiple documents in my related table and to do so I need another attachments control so once again I will copy this select my screen and paste it so this comes outside the context of the form control I will call this attach supporting docs control remove all the errors add a label called supporting documents and here I would like to allow the user to upload multiple attachments let's say I'm allowing the user to go up to 10 so I'll set max attachments for this control to 10. now at this point it's important to understand that the form control is related to my contract table and the supporting documents attachment control that I have added should be uploading these files to my related table the edit form control has a property called on success which will run only if the data and the form control is successfully submitted once this is successful only then I would like to read all the files from this attachment control and start patching it to my related table which is my contract supporting document table so on success before taking the user back to the previous screen I will Loop through all the attachments in the attach supporting docs control and for each of these I will patch to my supporting table which I will first connect in my power app patch to contract supporting documents I am creating a new file so I will use defaults of contract supporting documents and in here the contract lookup column needs the related contract record that I can directly get from my edit form control the name of my edit form control dot last submit and then for my supporting document column I'll create that object which has file name This Record Dot name and then value which would be this record dot value close the object close the patch update close the patch function close the for all function format the text here is the complete formula in action let's preview the app for contract a I will upload multiple supporting documents and I will click submit now on this screen where I have the details form to show the related files I'll copy the attachments card paste it same steps as before the display mode property of this attachments card I will use display mode Dot View since I would like the user to only view the supporting documents and to get those supporting documents for the items property of this attachments control I will use filter from the supporting documents table where the contract lookup column Dot contract that's the primary key is equal to the gallery selected item Dot the primary key which is contract so this should list out all the files however here you will notice that it's not showing the file name and the reason is because the attachments control expects two Key properties which is display name and value so we have to do some extra work here which is from this result get me the supporting document column and for all of these supporting documents create this object that has display name which would be this record Dot supporting document Dot file name and value which would be This Record dot supporting document dot value now once you do this you have to also ensure that you go to Advanced for this attachment control and make sure name is display name and value is value very important once you do that if I preview the app it will show me all those related documents and if I click on this it will start downloading those files if I create a new item notice that the supporting documents are already pre-loaded based on the last attached files so for this edit screen on visible we have to make sure that we reset the attachments control each time we visit the screen so now if I say I want to create a new item it's empty I create a new contract this is my single file column and this is my supporting files column where I can upload multiple files click submit all the data gets posted to my tables I pick contract C I can see all the files right here now if I go to edit the supporting documents will be empty so it's basically allowing me to keep adding to it but there's no option for me to delete existing supporting documents now you can write logic to do that with this attachment control itself but it could get quite complex an easier way would be I'll add an icon to my display screen and when the user selects this I will take them to a different screen where they can pick and choose the files they would like to Simply remove from that supporting documents table now this should only be visible if this attachments control has documents so the visible property for this delete icon would be count rows off my attachment control dot attachments is greater than zero so I'll add a new screen here I will insert a gallery pick title as the layout the items property for the gallery would be filter my related table where the contract lookup column matches the selected item of the gallery and inside the gallery the label control the text I will use this item Dot supporting document that's my file column Dot file name and for the icon I will change this to trash so when the user selects this all I have to say is remove from the contract supporting documents table this item so the user can go back to the previous screen and from my detail screen when the user selects this icon I will navigate the user to that delete screen so for contract C there are five supporting documents if I would like to delete them you can go to this screen and start deleting those supporting documents powerapps has controls that can display certain types of documents so if this were images that the user had uploaded we can show those by leveraging the image control or if there are PDFs like in my case I can Leverage The PDF viewer control to show those documents that I select in this gallery all I have to do is for the document property of this PDF control I will use gallery this Gallery Dot selected dot the supporting document which is that file column dot value so notice as I select this it is showcasing that PDF document 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: 35,282
Rating: undefined out of 5
Keywords: powerapps dataverse file upload, powerapps patch function, powerapps patch to dataverse, powerapps upload file to dataverse, dataverse file column, dataverse file attachment, dataverse, file, patch, powerapps, power apps, upload, attachments, microsoft dataverse, powerapps download dataverse file, powerapps save file to dataverse, powerapps dataverse file patch, powerapps dataverse upload multiple files, patch multiple files, dataverse file column type, reza dorrani, Patch, upload file
Id: RGJrUkgh_NU
Channel Id: undefined
Length: 20min 54sec (1254 seconds)
Published: Mon Dec 05 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.