web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Resetting a Combo Box ...
Power Apps
Unanswered

Resetting a Combo Box so I can add a new record

(0) ShareShare
ReportReport
Posted on by

I have a stand alone PowerApps form; I am not using the out of the box form; just controls.  


I'm having trouble resetting the a combo box so I can add a new record.   

Below is my formula which gives me the error "Expected Record Value".

My variables are working correctly on what I see in my "watch" labels and the action is behaving correctly on a text input field -- so the issue is not the variables working correctly. 

If(varNewRecord,"",LookUp(Gallery1.AllItems,ID = varChapterSelectedID,'cmbxClassification Record'.Selected.Title))

Thanks, in advance, for your help! 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @CindyZ 

    Can you indicate which property on the combobox you are trying to set - Items or DefaultSelectedItems?

    Either one requires a record.  You are trying to assign a Text - which will give you the error you are showing.

    I am not clear on your problem if you are trying to set the items or the default, could you clarify?

  • CindyZ Profile Picture
    on at

    Yes, Randy.  I'm sorry I left that out. I'm trying to reset "Default" since I have limited the  input to only 1 item. 

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @CindyZ 

    So you mentioned this is a Combobox - The Default property on a combobox does nothing.  You will need to set the DefaultSelectedItems property to get your selections properly.  And, it needs to be a record that corresponds to the records in the Items property of the combobox.

    If you can provide a little more context on your app and what the Items property is for that combobox, then perhaps I can shed some more light on it.

  • CindyZ Profile Picture
    on at

    Thank you Randy, 

     

    1. One Combo box has this in the items property - ["Global", "Local"] and that is the one that has the formula noted above. Would doing that as a drop down work better?   
    2. The other combo box has this in the items property - Classification which is a lookup into a collection.  I have not yet tried to add anything to the default items property since I felt sure I'd hit the same or a similar wall as the above. 

    CindyZ_1-1608155189654.png

     

     

    What I'm trying to do is clear these combo boxes so I can enter a new record.  Here is the formula for the "add record" on Select. 

    Also, here is my Patch Statement. 

    Set(varChapterSelectedID,

    Patch('B-E-RG Organizations',

    {ID:If(varNewRecord, Blank(),varChapterSelectedID)},

    {'Chapter Name': txtinputChapterName.Text,
    IsLocalChapter:cmbxLocalChapter.Selected.Value,
    Classification:'cmbxClassification Record'.Selected.Title,
    BERG:cmbxBERG.Selected.Title,
    'ID-ERG':lblBerglblInput.Text,
    Acronymn:lblAcronynmInput.Text,
    LocationNameOrg:cmbxLocationNameInput.Selected.Location_x0020_Name,
    PrimaryAddress1:lblPrimaryAddress1Input.Text,
    PrimaryAddress2:lblPrimaryAddress2Input.Text,
    PrimaryAddress3:lblPrimaryAddres3Input.Text,
    PrimaryAddressCity:lblCityInput.Text,
    PrimaryStateProvince:lblStateProvinceInput.Text,
    PrimaryCountry:lblCountryInput.Text,
    ZipORPostalCode:lblZipPostalInput.Text,
    LocationType:lblLocationTypeInput.Text,
    Level1:lblLevel1Input.Text,
    Level2:lblLevel2Input.Text,
    Level3:lblLevel3Input.Text,
    Level4:lblLevel4Input.Text,
    Level5:lblLevel5Input.Text,
    ConcatenatedChapterName:lblConcatenatedChapterName.Text}).ID);

    UpdateContext({varEditing:false,varNewRecord:false})

     

    Even though my Patch formula does not show any errors, I just now saw that it is giving me this message...

    CindyZ_0-1608155042563.png

     

    Finally, I am following along using PowerApps 101: Create your own forms – Giacomo Baizini's business IT blog (baizini-it.com) which was working great until I hit these combo boxes. 

     

    Hope this was not too much and that it is helpful. 

     

    Cindy 
    "

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @CindyZ 

    I'm starting to dig into what you sent, but I have one particular question, is there any particular reason for building this with your own controls over using the built in EditForms?  It would be much easier for you as you would not need these long Patch statements.  This is more of a curiosity question.

     

    As for your #1 question - Yes, you only have two items in your Combobox.  This would be easier to handle if that was a DropDown.  Comboboxes bring the ability to search and to multi-select.  If you do not need those capabilities on that control, then always favor a Dropdown rather than the combobox.

     

    As for #2 - I believe I am close on what you are doing, but need some clarification...you mention that the Items property is based on a Collection - what is that collection and how is it defined?  But, I look at your original formula you posted and see you are Looking up some value in Gallery1 - how does that fit into what you are doing.  I am not seeing the connection for that yet.

     

     

     

  • CindyZ Profile Picture
    on at

    First of all, Randy, thanks so much for your kindness to help and the manner in which you ask your questions.  I'll try to answer them as best I can. 

     

    Why did I go the route of Patch.  First of all, a co-worker looked at an app I'd built one time and commented on the number of calls I was making and said it was slowing my app down. My app does include a number of SharePoint lists that cannot be in a single list.  He said, prior, I should be using Patch -- which I was terrified of.  He is someone whose work I respect and he has built a number of apps.

     

    I have wondered, throughout this process, why so many of the blogger and community leaders have used forms instead of standalone controls while I'm stumbling around here --- but I will say I've enjoyed learning Patch and using it and I do like the flexibility. 

     

    I do not like the room the out of the box forms take even if I do adjust them but I can live with that if that is the best route to go.

     

    Also, another reason is that another tutorial I had been working with/following along on this project also used Patch.  But, really, the only true reason was I was guided to use Patch over Submit was because that is the direction in which I was led from multiple fronts.    So, there is that answer. 

     

    I'd also like to say here your question and my reply points to a tremendous gap in learning/knowledge that is available -- the ability to understand the approach to and the why of particular situations.  I have read plenty on Patch versus Submit and get very divided opinions.  Another current question I have is: This particular solution I'm working on has a number of different but related forms and every day I wonder -- should I make it one app or make it several apps.  I still don't know the answer.  The lack of guidance on strategy and the lack of complete solutions from start to finish I find baffling since we're out there on our own to piece so much together if we want/need to do anything complex. 

    Frankly, Microsoft promotes how easy PowerApps is to use that sometimes we don't even know we're into a complex app until we're far down the road already. The comprehension of learning materials and the knowledge also, of course, change with the education and experience of the user.  We are in the process of hiring some assistance for me for those times I hit a wall. And I do appreciate the simplicity of PowerApps in some situations but, it does not work in so many of the situations I face. 

     

    So, there ya go - probably didn't anticipate that can of worms, huh! 

     

    I'd not even thought of using a drop down on that first item until I replied back to you -- I was focused on the dilemma I suddenly faced with four combo boxes that I'd frankly not expected to run into.  I do need multiple choice selection  and search in the other combo boxes which is the reason I chose those. 

     

    I'm not sure what you mean on the definition of my collection.  But, in this case it is a simple one column collection that I load along with others.  I'm sure this one does not need to be a collection but my other  collections do since they are multi column with a large number of choices/records (facilities for examples).  

     

    The gallery I refer to is simply a gallery view of the records I'm creating and submitting. I am using that to search and select the record I want to update or modify.  Unless I'm far off base, that seems to work fine in interaction with my form.

    Thanks again !   




     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @CindyZ 

    Yep...here it is.  It was only 4 tabs deep in my list of catch up work.

     

    So yes, Patch has its place, but if you have an easier method (i.e. the form) then go for simple!  Patch patches records together.  Interestingly enough I don't see many conceptually using it for that purpose it was intended for, but rather "it is how you write stuff to a datasource".  Anyway, that's a side story.

     

    I would recommend watching my comprehensive video on Forms that will tell you everything you ever wanted to know about them and things you might have never imagined you could do with them.  It will show you how to really make a form look exactly like you want and how to even separate out the power of the EditForm from the visual of the form (which is, as you say, kind of ugly with the spacing).  It's a long video, but there is a table of contents to get to key parts of interest.

     

    Also, everyone uses collections and variables - avoid them at all costs!! (not to say they don't have their place, but people overuse them and, there is where you start dealing with complicated app formulas, issues with data, and just a royal pain to deal with).  Keep this in mind...a datasource IS a collection!  So, unless there is a compelling reason to use a collection, leave it in your toolbox for when it is really necessary.  We have tons of complex apps and in most you will find no collections and very few (if any) variables.  They are not needed and even the PowerApps docs warn you to not use unless really needed - and take my word, there are times when they are needed.  BUT, you will find tons of "learning" stuff out there - I find a good 80-90% is really poor advice.  Most talk about a variable for this or a collection for that, timers to do something that is already automatic, ForAll used as a loop to create a collection in a collection from a collection...etc, etc...I could rattle on. Most represent the presenter has not mastered the platform. This is why I've devoted time to do videos that are all about the REAL simplicity of PowerApps and how to nail an app in as little time as possible with the smallest amount of formulas etc.  I will give a hint - Think Excel!!!  Anyway, it is just an issue of finding time to do the videos.  And...I'm not trying to puff myself up, just stating that the ways people go about things is just so very wrong and complex, when the solution is so simple.

     

    As for strategy - Yes, there are ALWAYS design choices you have to make.  In regard to the multiple forms vs multiple apps, I balance it between two things:

    1) Do I have the same functionality that I would have to duplicate in the apps?  If so, then one app as you don't ever want to have to deal with a formula more than once...that means even - NO copy/paste of MEANINGFUL formulas ever! (highly simple formulas for things like positioning, etc. are okay)

    2) Does the impact of multiple datasources play a role in performance in some way that I can't block it?  If so, then multiple apps, if not, then one app and block.

     

    Actually Microsoft does promote the simplicity of PowerApps, but they provide sample templates and guidance that is *poorly* done to really emphasize the simplicity.  AND many people are coming to PowerApps with a developer mindset...PowerApps is NOT development!  The more developer you are, the more trouble you will have.  You have to drop the hat at the door.  Again...think Excel!!  It's all about formulas!  PowerApps is best suited for Excel Power Users (not people that make worksheets look pretty, but people that can crank out a formula in a cell like it is nothing).

     

    So...tasty can of worms opened! 😉

     

    Now, back to the story!

    Yes, this is why, as I read through your original post and reply, I wondered why not just use an EditForm where all of this is done for you so easily.  

    As for the collections, I would say get rid of them as much as you can, you don't need them in the way.  I was referring more to whatever the collection was that you had on the Items property.  What is it?  What formula defines it?

    As for the other collection, again, consider dropping the collection - what is the formula for that one?  You seem to indicate it is complex...explain more on that.

    Now for the Gallery...yes, very basic.  
    So the reality is, a simple Gallery like you have can feed an EditForm completely with what it needs and all the Patch work is eliminated that you are doing and we can certainly incorporate the dropdowns into the form (in fact, the form will do that for you in most cases - watch the video).

     

    So, first, sorry for the delay in response and let me know what your thoughts are.  If you any questions...bounce them at me.  

    And - happy holidays!

     

     

     

     

     

     

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 528

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard