How to set default value to a Combo box in a PowerApps form

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] in this video I want to show you how you can set default values to a combo box not just a regular combo box I want to take it to the next level and I want to show you how you can set the default for a combo box that is part of a form and that form is actually connected to a dataverse table with a lookup field let's see how we can do that before we start let's have a quick review on the setup inside Power Platform I created the solution that is called default lookup value that has two tables only one of them is product category which is the list of the categories that are available for the products that you want to add to the other table and that other table has the product name unit price units in the stock and the last one is YouTube category which I got it from the product category so every item that you see under YouTube category is one item from the product category that is the other table all I'm trying to make the videos on YouTube in a way that everybody can easily understand that right in the beginning I want to have a quick note for the experienced developers so that they can watch maybe a minute of this video they get the point and they leave us alone so that we can comfortably sit there and have our chit chat so experienced developers here's your one minute powerapps combo box has two properties one of them is items that this items property can accept a table array or collection so basically these are the items that the combo box are gonna display as the choices that the user can pick at the same time powerapps Combo box has another property called default selected items remember this table whatever that's going to be the default value just filter the sky and stick it in here that's it every time that you reset that combo box it's gonna show the filtered items as the default value now that you got your point leave us alone because now I want to get back to basics so this is the solution that I created which is called default lookup value and inside it I have the product category and the YouTube product I create a new app quickly canvas app and I call it YouTube product management [Music] and I click on create and here I want to create a screen I call it scr underscore products list and here I want to show the products that I have in that table so I quickly make a connection to this table that shows the products so I click on add data and I call it YouTube products there we go and I add the data table here so data table and I picked the YouTube products from here and it shows me only the product name and the created on I need to readjust it a little bit I don't need the created on remove and I just add a few more Fields the fields that I need are category which is my YouTube category add I want to add another field which is unit price and the unit in the stock so unit price unit in stock and I just add them now the YouTube category shows you a weird value which is not what you're looking for just look it up because it's a lookup field it says Hey probably they need to see the ID they say no we don't want the ID we just replace this IDE by name so now it looks the category properly which is not a big deal our challenge starts when we want to add another screen here let me say adding a new screen and I want to call this a screen scr add new product and in this new product I can use the edit form insert click on the sky forms edit form and because I want to use this edit form to add new product the default mode is going to be new the data source I want to pick it up from the YouTube products you know I hate forms with three columns I pick one column I don't need this created on let me get rid of it and the fields that I want to add here are the same Fields as of YouTube category the other fields that I want to add are going to be units price and units and stock and I click on ADD okay at the moment if I just run the sky I have a drop down that shows me the list of products I can pick one of them or the other one and it's all good and if I want to add this let me just let me add a button here I go to icons and I just pick the save button bingo let me just add this one here increase the size a little bit Ico underscore save and unselect I want to tell this guy submit form and the form that I have is form one and right after that I want to say navigate and it's going to be to the product list and you all know I like fade I close the sky and I just expand this so you can see what's going on here so I submit the form and then I navigate to the list of products let's test it quickly and see if it works I say my test product from app let the category be art equipment unit price is going to be for example 10 units in the stock we have for example 20 and I click on Save and you see that the product my test product from app is added here so we are all good maybe you want to add another button here let's say icon Plus to add and this ad is not going to do anything but going to the other screen so unselect let's say navigate to scr add new product and again fade and I close the sky if you're good so let me just save it quickly I don't want to share it with anyone and we're good so now our app works this way if I click on this plus it takes me to this new screen this form needs to be reset when we come to the screen so let me just pick this screen quickly and on visible I would say reset form and that's going to be form one there we go so this time when I go back to my product list and I run this I click on this guy it shows me a fresh form the only thing that we need to do now instead of blank category we want to pick for example food for the category and this is where our work Starts Now first of all let's see the items in the sky so let's say pector combo box I click on Advanced and I unlock it and here you see it shows you the choices of YouTube products dot YouTube category what does that mean in powerapps we have a function called choices choices is a function that returns a table or an array it takes a table it takes the column name as long as that column is lookup or Choice the choices returns a list of everything that can be selected for that specific column if I ask choices to go to the YouTube product dot YouTube category it says okay what are all the possible options that I can pick for the YouTube category and it immediately gives me a list of all these items from the product category let's give it a shot and see what is exactly inside it to do that I add another dummy screen here I don't want to rename it it's not part of my solution I'm too lazy for that but I go back to the add new product I picked this guy and for the items that I have I get all of them I come back to this screen I add a new data table here and instead of picking anything from here I go straight to the items and I add this guy here so you see it shows you the name and Creator done it doesn't really matter I go to the properties again and I say edit fields and I see what is there I don't need created on and if I say add Fields you see all the fields that I have in the other table are actually present here so it's literally a table so choices returns me a list of all the items that they can be selected here and you have lots of fields here so if this is a table and for example for default I want to say arts equipment all I need to do I need to come back here and I say filter whatever that you have here for anything that this record Dot name equals to Arts equipment and I close the bracket and that's it and it shows uh it doesn't but why it doesn't show us anything we have arts equipment spelling is correct you can compare it here arts equipment it looks okay to me so what are we missing here I literally see the plain text up here if this filter is not there look at that true so let it show everything here arts equipment why this guy doesn't show it to us simple because when we are working with the lookup field it doesn't really have a data type so it doesn't do a true comparison of something like this with the string to solve this problem whatever you get here you need to convert it to plain text open the bracket so whatever the name value is we put it in the bracket and I just save it and as you can see now it shows you the art equipment we cut our filter I just copied this guy and I bring it to my other screen for the new product YouTube category I pick the combo box just make sure it's unlocked now we got the value from the items we filtered it whatever we have we go to the default selected items and instead of parent.default I just take this guy out and I stick it here how do you like this one now I can save the sky I can go back to the first screen run and if I click on this guy arts equipment is selected even if I change it to toys for example I enter something here unit price units in stock and I just save it and I go back here again you will see art equipment is selected default value and now you get the point where I was talking to the experience developers I said whatever you have in the items whatever the expression that is there it doesn't really matter filter it and put it in the default selected items and this is how you get default values for the combo box that was all about it I hope you enjoyed this video if you did like button is right under this video thank you for watching and I'll see you in the next video foreign
Info
Channel: Alireza Aliabadi
Views: 21,068
Rating: undefined out of 5
Keywords: set default value to a Combo box in a PowerApps, powerapps form, powerapps edit form, powerapps dataverse lookup default, dataverse lookup default, powerapps combo box dataverse combobox, dataverse looup, power apps set combobox default, powerapps edit form combobox set default, powerapps edit form dataverse lookup, powerapps tutorial, power apps tips
Id: rEER1Fo2v0U
Channel Id: undefined
Length: 13min 35sec (815 seconds)
Published: Tue Aug 30 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.