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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How do I set the defau...
Power Apps
Unanswered

How do I set the defaultselecteditems of a combobox using a value from a choice set

(0) ShareShare
ReportReport
Posted on by 92

Hi,

 

I'm struggling to set the defaultselecteditems property of my combobox with a value from a choice set that I have.

 

I'm using Microsoft Dataverse for storing my app data.

 

Here's the code I have under the DefaultSelectedItems property:

 

If(
 DataCardValue5.Selected.Value = [@'Timesheet Type'].Holiday,
 ["30"],
 [Parent.Default]
)

 

Essentially this is saying if the user selects the value Holiday in a separate combobox, then set the DefaultSelectedItems of this combobox to "30", else Parent.Default

 

Now when I run the app and select "Holiday" the combobox appears to be set as 30:

 

Capture.PNGBut it's just added the text "30" to the box, it hasn't actually selected the choice value 30. If I click the dropdown arrow for the combobox you can see that the "30" is not actually selected:

 

Capture 2.PNG

 

Here is what the above image would look like if the 30 was actually selected:

Capture 3.PNG

 

When I submit the form the field is also left blank. How do I write the above code so that it actually selects the choice set "30" and saves it to the record?

 

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

    Try this

    Set DefaultSelectedItems for combobox is

     

    If(condition,{Value:30},{Value:ThisItem.'ColumnName'.Id})

     

     

    Example (Actual and changed using default)

    StalinPonnusamy_0-1627662727519.png

     

  • Verified answer
    Omainesi Profile Picture
    92 on at

    Thanks for your reply, I tried your suggestion but was unable to get it to work. The solution didn't have any errors, but on form submit the field was still empty.

     

    I've persevered and spent another 2 hours on this tonight, taking my grand total on this problem to about 6 hours 🙄 but I've finally figured it out:

     

     

     

    If(
     DataCardValue5.Selected.Value = [@'Timesheet Type'].Holiday,
     [[@'Start Time Minute'].'30'],
     [Parent.Default])

     

     

     

    So for anyone who comes across this in the future, here's a breakdown:

     

    If(DataCardValue5.Selected.Value = [@'Timesheet Type'].Holiday,

    The above checks the selected value of a combobox to see if the value "Holiday" is selected, if this statement is true then it:

     

    [[@'Start Time Minute'].'30'],

    The above sets the value of the combobox in question to '30' (@'Start Time Minute' is the name of my choice set for this combobox and '30' is one of the choices).

     

    [Parent.Default])

    Else it sets the combobox to Parent.Default

     

    A final point to note was that I mentioned in the original post that my code only appeared to be adding the text "30" to the combobox, and when I clicked the arrow to view all the options, '30' wasn't highlighted. With the above code, it was still not highlighting the '30' as selected, but onsubmit it was saving "30" to the record. Strange, but to be honest I'm just happy it now works.

     

  • Golly Profile Picture
    127 on at

    The brackets around [parent.defaultare important in this case, fyi.  I spent way too long trying to fix the table value before finding this post and realizing I just needed brackets around parent.default.  Thanks!

  • Luminait Profile Picture
    on at

    Thanks so much for sharing your solution. The brackets were keeping me from accomplishing my task and you solved it for me!!

     

  • Suggested answer
    Tim Surgison Profile Picture
    2 on at
    I had tried many ways to work around the issue, then found best was is using
     
    Table({ColumnNameOfItemList: ValueOfDefaultValue})  
     
    in the DefaultSelectedItems property.
     
    For the original example first code snippet in the DefaultSelectedItems property replace
     
    ["30"]
    With
    Table({ColumnNameOfItemList: "30"})  
     
    NB: ColumnNameOfItemList is the column name of the name of the column in the source of the Items property  

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard