Saving Power Apps Data with the Patch Function

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi today we're going to talk about saving data in powerapps what we're going to do is we'll learn about the patch function right we all know how to save data with forms we all start with forms but very quickly you outgrow forms because you want to build more complicated apps with more moving parts right whether it's barcode readers or address inputs or using collections or variables right like very quickly all of a sudden it's like hey using the forum's gotten really weird so that's why Microsoft has us the patch function which allows us just to take individual inputs and create new records in our data source so today we're going to do patch 101 we're going to start at the beginning and explain to you exactly how it works if you've used it before and you're like I don't really understand but I kind of understand this probably a good video for you because we're going to go through a very structured way of patching those core columns all right so let's just jump over to my desktop and take a look over here on the desktop we are going to start with a blank app I just created a literally blank app but nothing else and the first thing we need is a data source right you're going to want to save data to what we call a tabular data source so think of that like your SharePoint list dataverse tables SQL tables something like that some structured data so for us we're going to use a SharePoint list but nothing about this is going to be SharePoint specific specific whatever that word is so we're just going to go up here add a data source we're going to search for SharePoint after way too long it finally loaded we're going to choose SharePoint choose one of my SharePoint connections and then over here we're going to use my powerapps video site and we're going to choose the employees list right so with all that chosen we'll click connect down there at the bottom under my face and so now we have a tabular data source and then what we're going to do is we're just going to add a gallery so insert a vertical Gallery in here the gallery is not really part of this but you got to be able to see what you've done right so that's what we're going to do and we'll kind of drag this down here we'll make a couple of quick changes we're just going to throw people's name in here because I know that I end up referring to them as their name and then we're going to just drag this up here and we're going to patch a couple other fields so copy this one copy paste or drag it below and for this particular one we're going to do their age and then we're going to do one more paste so click out of there and paste put this down here we're going to then do their higher date actually let's do one more as well so we'll paste we'll make this bigger one more time and then we'll paste one more time again pull this down here and this one we're going to do good at their job right and so these are the fields we're going to learn right we're gonna learn text we're going to learn age which is a number we're going to learn higher date which is a date and then go to their job which is yes no in SharePoint but a true false and so like if you're using SQL this would be a bit field or in data versus yes now so yeah so those are the fields we're going to update the other thing I want to do just to make this easier on us in a minute we're going to do a sort by columns here and we're going to sort by the ID column I'm going to do that descending that way the latest one that I make goes up the top and just to get rid of this you know what we're going to add one more thing in here we'll do a remove employees this item and so that way we can delete this all right so there you go so we just have our core data that was for my practice wrench and so now that we've got this now what we want to talk about is how to create a new record using patch and so we're going to do is we're going to start the most Basics we'll insert a button and we're going to write the simplest patch ever and so to do that we're going to say patch that's a new function then it says all right what table do you want to update and this could be like our SharePoint list or our dataverse table this could also be a collection any tabular data source but for right now we're going to use our SharePoint lists now this is all right well what record do you want what this is really saying is hey do you want me to create a new record or do you want me to update an existing so to make this as easy like foolproof as possible we're going to do create a new one so we're going to do defaults and then the same list name so if your list is name something different then you would have that there right so that just says create a new record in employees boom just like that the third piece here is we have to have a record so in powerapps records are always in curly brackets like that so if we close our parentheses technically that's a valid patch statement that would patch a blank record in theory but because we have a required column it would work but we don't care right but that's the structure that's where I need you guys to start so now we want to patch this person's title because that is the required field so I'm going to type it and start typing my column name notice that I start to type that in it auto suggests so it's going to be title colon right and using the auto suggesting is going to help you when you're using your data for the first time because it'll be different than mine right and so title is a text column so we're going to have some text and we're going to say title goes here just like so notice it's in double quotes notice that I can hover like this and if I highlight that it says hey that's the title The text title goes here data type is Text data types are the hardest thing about this you've got to give it what it wants right the golden rule in all my training classes live on coming up soon you should go sign up is powerapps just once what powerapps wants in this case it wants a title column and so title is text and so we just have to give it text it doesn't matter if it comes from hard-coded text there comes from a variable comes from a control which we're going to see here in a second all right so let's just try and press that button so we hold down the ALT key you can press a button and interact with so we press that you're going to see for a second it blinks and goes back and look at that it has created a new record in our SharePoint list called title title goes here that's the first piece of information we needed so now that we've seen how that works now what we might want to do here say format text and the reason you want to do this format texting is it breaks it out into the pieces a little easier to visualize so there's title goes here now we want to update another field so we also want to update first name so we just do a comma here we'll start to type in first it'll Auto suggest the first name column and it is also a text column and so we'll just say FN for first name look at that it's happy do the format text again now to break them across multiple lines even easier to read all right now what if we want to do age and we're not going to create them every time right we're going to just one time so I hit enter here I'm going to start typing H there it is auto suggest we'll hit tab now age in this case is a number column so number columns means I have to give it a number because so if I type in this it's going to yell at me anytime it yells at you I always want you to go hover it's going to try to help you the type of argument age does not match the expected type number found type text if you were to highlight this 12 what's it going to tell you it's going to tell you data type is text it doesn't want text was it one what's a number so instead of that we're going to delete it out and we'll just type in 12 like that now it's happy data type is a number it's getting the number it wants this is the hardest thing for people with patch just once What It Wants give it what it wants comma let's hit enter again same thing for sort of type in higher date right there's higher date higher date is a date as a text column or sorry it's a date column so we're going to give it a function that returns a date in this case the today function returns a date now in a minute we're going to use different inputs to kind of see how this works but right now right hard coding these and I can't stress this enough do it this way when you're learning and then in a minute we're going to kind of make it harder and harder and harder but this like like this is foolproof basically right like we're not leaving anything up to chance we don't have extra moving parts let's get it working the easiest way and then troubleshoot from there so the last one hit enter again this is going to be good at their job tab and what is good at their job it is a yes no or a Boolean and so in this case we're going to say good at their job and we'll say false it's a little bit different for that one like I probably wouldn't try this one in a data versus begin with because that one's going to require a different thing we're not going to get into that complexity today but for right now that would work okay so we've got all these in here let's see if this works we'll kind of grab our little button here we'll hold down the ALT key we'll press it it'll think for a second look at that title goes here FN 12 today's date and false which is exactly the same stuff we had up here yes we're doing it folks there's our first patch almost full proof okay now let's go a step further because probably don't worry we want to patch a bunch of hard-coded stuff I get that what do you probably want to patch you probably want to have inputs right you want to kind of create your own form so what we would do is we can go over here to the insert and we're going to say insert a text input we're going to drag it down here and we're going to clear out the default value and we'll also go here to the left I'm gonna double click on this and rename it to inp FN like so right you don't have to rename it but watch how much easier this is going to make our lives so now for first name instead of this FN what do we want we want inp FN right our control and look if you put the cursor here it's going to tell you I just highlight this thing data type is control can is SharePoint expecting a control no right SharePoint is expecting text so what do we need to do we need to drill down into that so we would do a DOT at the end and now it says hey here's all the properties I know about that the inputs have a text property input Evin has the text of it's blank right now but it is text so if we were to go and hit play and then we were to type in um buddy then what now if we go back and look here if we patch this thing look input FN is Buddy and it is data type text is exactly what it wanted so it was double check make sure it was hit hold ALT key look at that there is title goes here buddy 12 blah blah blah blah right because we didn't change any of the other ones we only made this one an input what if we want to do age all right insert another text input we're going to rename this one to inph we're also going to get rid of the default text and maybe you're really fancy like hey I even know that I can go over here to the right I can change the format of that from number to text cool we'll hit play we'll type in one because buddy is almost one and then now if we do this what are we going to do we're going to go back up here now remember what did you just tell me this once this one's a number that's going to be important two seconds so we're going to do imp h that's the control we can't use the control so we're going to do dot now there isn't a DOT number unfortunately text inputs only have Texas outputs so if we do this we're going to get an error but chain we typed in the right thing we used to have complete we could have messed up hover in type of argument right age expects the number you gave it text but it's the number one no it's the text one it's not the number one so what do you have to do in this case you have to use what is called the value function the value function turns the text 1 into the number one ah look now if you highlight this puppy it outputs one and data type is number that made age happy as you can right we won't test it but we now know that would work now what about for higher date well for higher date we could do an insert we could insert a date picker we pull this down here and now we're back to this again right so we're going to do oh let's rename that thing right let's stick with that DP higher okay we're gonna go here and now we're going to replace this right what is this this is currently a date so we've got to make sure you get a date here so we're going to do DP higher Dot selected date look at that that shows that that is a data type of date boom it is working last but not least good at their job um you know we could do some bunch of different controls up here but and right and what's important to understand is it just wants true or false so we'll just do the most classic one we'll do a toggle so if we throw a toggle down here we could rename this to be tgl um good and so the way the toggle would work we'd go back up here and we'd say hey good at their job tgl good Dot value what does that return that returns a data type of Boolean yes no true false Boolean it's currently false if we hold down the ALT key and click on it it's now true all right now we didn't do title because title and first name are both texts they both work the same way we could we're not going to but then so all we got to do now is we'll hit play and let's just take all those see what happens title goes here buddy one June 2nd Drew if we deselect that we change this date to June 7th and we change this to Buddy Junior oh that would be crazy and 13. press it again buddy Junior 13. bingo bingo you can now patch all of the core Fields right and that's what we're after here but Shane what if I want to update one of those great question so remember this part right here this second section second line Second section of commas whatever you want to call it this controls things for you when you put defaults and your table name here that says that's code for it make me a new record right there's more technical explanation but what if we wanted to have it update a specific record from the gallery well what we could do is we could say instead of using that record here I just don't know where I'm going we're gonna go right here and we're gonna say all right well my gallery is called Gallery one it's a gallery one Dot select it gallery1.selected is the currently selected record easy way to visualize it click on your gallery so I was trying to do a second ago go down here to template fill and you can say Hey what if we change this to Red oh that's crazy so that would work though right but we can do this we can say if this item let's move my curse out of the way dot is selected so that's true then we want to make this um my one of my favorite colors medium aquamarine if not we'll make it um teal let's just see how ugly we can make this thing so now right they're all teal but if we hit play and we click on one look at that yeah so that's telling me that this is a currently selected record and so then if we went back to here Gallery one dot selected will now update with whatever's in there so right now it says title goes here buddy you know one blah blah blah so this will change all those values to these things and Roses change into something different we'll change it to 133 June 5th good at their job and Buddy junior junior sure who cares right so if we press this patch button now same thing's happening it didn't create a new record though it updated this record right and it updated it in SharePoint it updated in our Gallery everywhere This Record is now to that value well Shane what if I wanted to see the values that were in the selected one over here then what you would start doing is you'd have to start changing all these defaults so like this default would then be um Gallery one dot selected dot uh what was that first name first name and so then now as you click through these you'll see that the first name field is updating to the different people's first names and so you would repeat that same pattern right that's not the point of the video so we're not going to go that way wait leave me a comment below if you need me to go that next step but we're not after that today right right now I just want the core how do I use patch and I think you've got that here also keep in mind like this Gallery one dot selected you're going to outgrow this you know kind of like how you just outgrew forms you got the patch eventually you kind of outgrow things like gallery.selected you start using a variable called VAR record you know what I'll put a video up there to a link that talks about using a variable instead of gallery.selected but that's that's okay right the first thing I want you guys to do is just go back to that simple button that we made in the beginning right patch you're listening default you're listening and then work through those fields with just hard-coded values troubleshoot your way through that and then worry about adding these controls then worry about doing records have been modified then worry about getting the controls to populate like it's a journey right it's it's but it's baby steps but this one was about getting you comfortable with patch also I skipped a bunch of the columns you're saying oh Shane I want to do a SharePoint Choice column or a lookup column or any of those so another video up there there's a whole like half hour video it takes to teach you about all those because they're they're harder and we wanted just to make this approachable so questions comments things I can help with tell me down below I I'm here to make these videos for you guys all right I made the first version of this video like five years ago I got 200 000 views so you know we're uh we we like to help people here I just need to know what you need to know also keep in mind you know here powerapps 9-1-1 we have full-on training classes we do on-demand we do live training we do Consulting we do mentoring we do like quick little just help you fix one little formula and things like we have a whole Litany of Power Platform services for you so there's powerapps power automate power bi power Pages power virtual agents power desktop that matter we got your back all right and with that I'm gonna say thanks and have a great day
Info
Channel: Shane Young
Views: 43,265
Rating: undefined out of 5
Keywords: PowerApps Patch Function, PowerApps patch SharePoint, powerapps patch new record, Shane Young PowerApps, PowerApps911, powerapps patch examples, patch function in powerapps, powerapps tutorial, powerapps tutorial for beginners, powerapps tutorial sharepoint, powerapps tutorial video, powerapps tutorial youtube, Patch Function, Create Records, Microsoft Power Apps, Power Apps Training, Power Apps Guide, Power Apps Tips, Power Apps Development, Power Apps for Beginners
Id: W8JjF2k0IQA
Channel Id: undefined
Length: 17min 59sec (1079 seconds)
Published: Mon Jun 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.