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 / How to set the Default...
Power Apps
Answered

How to set the DefaultSelectItems as Parent.Default on a ComboBox

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi All

 

Hoping someone can help as I've been struggling with this for hours

 

I have 3 ComboBoxes that I am trying to set the DefaultSelectItems for.

 

Depending on whether the screen is in new mode or edit I'd like the ComboBox to either say 'Find Items" for new mode, or pull the parent value from the gallery if it's in edit mode

 

This formula which works in the InputTextPlaceholder field but not the DefaultSelectedItems field?

If(EditForm1.Mode = New, "Find items", Parent.Default)

Which is frustrating because it looks like the value is there, but it's not really so the user has to select them again before resumbitting the form (as they are required fields)

 

Any help would be appreciated
Thanks all
V

Form.png
Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    What values Do you have on the Items property of your combo box? Is "find items" one of them?

  • KroonOfficeSol Profile Picture
    587 on at

    @Anonymous

     

    I really don't understand what you like to do. 

    You should know that the InputTextPlaceholder is just a guiding for the user which is visible when there is no selection. On a new form there is no selection so this text is visible by default. If not, then you probably turned off the search option for the combobox. So it makes no sense to set a formula like that for the InputTextPlaceholder .

     

    For the combobox. To set the ComboBox.defaultSelectedItems attribute you have to use the lookup() formula, like:

    LookUp(YourTable, ID = Parent.Default)

    On a new form there will be no Parent.Default there so this means there is no selection by default.

     

    Want to set the combobox to a default on a new Form? Then use this formula:

    If(EditForm1.Mode = 1, LookUp(YourTable, ID = YourIDSource), LookUp(YourTable, ID = Parent.Default))

     

    Hope this helps,

     

    Paul

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @KroonOfficeSol

    Thanks for the reply

    I do know the InputTextPlaceholder is just a guide. I just couldn't understand why my formula worked in that field and not the one I needed it to, DefaultSelectItems  😕

    So I am trying the Lookup function as you suggested. But I cant be doing it right as it's still not populating the ComboBox with the supplier name on that record (it should be showing a selected item of "Jurys" as that's what's on PO 1125 in my table [dbo].[MobilePOLog])

    If(EditForm1.Mode = New, LookUp('[dbo].[MobilePOLog]', PONumber = Value(Parent.Default)))


    Can you see where my formula is wrong?

    PS. I had to convert the Parent.Default to a value otherwise I was getting a mismatch error saying the formula couldn't evaluate as the left was a number and the right was text

    Thanks again
    V

    DefaultSelectedItem.png
  • Verified answer
    KroonOfficeSol Profile Picture
    587 on at

    @Anonymous

     

    Select the datacard and unlock it. Then put in a label and connect this to the Parent.Default. You will see that the label is empty. And this is offcourse normal behaviour on a new form, because there is not yet a selectedItems written to the database 😉

     

    So there's your problem: you want the default to appear in a view or edit mode. Do This:

    If(EditForm1.Mode in [0,2], LookUp('[dbo].[MobilePOLog]', PONumber = Value(Parent.Default)))


    In case you want to set a default to a new form then you use a local variable to set the PONumber you like to set as a default. On the button starting the new form you do:

    NewForm(YourForm);
    UpdateContext({PPONumber:ThisItem.PONumber})

    On the Combobox you do:

    If(EditForm1.Mode =1,
    LookUp('[dbo].[MobilePOLog]', PONumber = PPONumber) ,
    LookUp('[dbo].[MobilePOLog]', PONumber = Value(Parent.Default))
    )

    On the Form.OnSuccess you reset your variable so the next time when you do a new form and don't set the variable there will be no selectedItems. Like

    UpdateContext({PPONumber:0}) // on a number
    UpdateContext({PPONumber:""}) // on a string

     

    I use P in front off the variable to show it's a Input Parameter

     

    Still it's strange that the text-number flag appears. This means that in one table the PONumber is an int and in another a varchar. I think you should check this and change this if you still can.

     

    Hope this helps.

     

    Paul

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @KroonOfficeSol

    I knew what you were saying had to be right but I still couldn't get it working

    So I created a new app and low & behold... your formulas worked!

     

    I went back to my app to figure out what was causing the problem, and it's my jazzy formulas in the ITEM property of each of the 3 ComboBoxes -

     

    1. The first simply filters to distinct results only:

    Distinct('[dbo].[SupplierServices]',Supplier)

     2. The second filters results by what's in the first ComboBox

    Filter('[dbo].[SupplierServices]',Supplier=ComboBox1.Selected.Result)

    3. And the last one just sorts the employee names in alphabetical

    Sort('[dbo].[StaffRegister]'.InitialSurname,InitialSurname)

    But if I paste these formulas into the ComboBox ITEM properties it breaks the DefaultSelectedItems?

    I can't believe you have to chose between setting a DefautSelectedItem or filtering/sorting
    Perhaps I am pasting the forulas into the wrong place?

    But that probably needs to be a new question/post

     

    Anyway you for helping me get to the bottom of it!
    Regards

    V

     

     

    DefaultSelectedItem2.png
  • KroonOfficeSol Profile Picture
    587 on at

    @Anonymous

     

    Change the sort() to SortByColumns() and try if it works then? Maybe the sort gives back only one column off items and not the record/object.

     

    Let me know if it works.

     

    Paul

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    That works perfectly! Thank you Smiley Very Happy

  • Xavierdefrance Profile Picture
    12 on at

    Bonjour, 

     

    je pense avoir le même problème 

     

    Je recherche a faire apparaître le nom du fournisseur par défaut en mode édition qui serait dans mon cas AIR THERM. lorsque que je met la formule dans DefautSelectitems il me trouve les données mais ne me les affiches pas.

     

    Auriez-vous une idée pour m'aider à résoudre mon problème 

     

    Cordialement 

     

     

    Screenshot_20220404-122514_Microsoft Remote Desktop.jpg
    Screenshot_20220404-122504_Microsoft Remote Desktop.jpg
  • Xavierdefrance Profile Picture
    12 on at

    Ce que je trouve dingue j'arrive à le faire avec une entrée de texte 

    Screenshot_20220404-232136_Microsoft Remote Desktop.jpg

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 490

#2
WarrenBelz Profile Picture

WarrenBelz 375 Most Valuable Professional

#3
11manish Profile Picture

11manish 302

Last 30 days Overall leaderboard