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 / Setting Default of a D...
Power Apps
Answered

Setting Default of a Dropdown based on the value of a field

(1) ShareShare
ReportReport
Posted on by 69

I want to save the user time when filling out my form so Im trying to store their choices in a datasource. When the app opens it grabs the currentuser and pulls their record in this datasource into a hidden form in the app. I then want the default values for certain fields to be the values in the stored record for the current user.

 

Example:

First form the user sees is a dropdown (called "Letters") with these possible values: A, B, C, D The last time the current user was in the app they selected D. 

When the app opens it grabs the users record from my datasource and puts their Full Name and their last choice for the field Letters.

I want the default value for Letters on the first form to be "D"

 

I can pull in the record into my hidden form no problem with  Lookup() but I cannot figure out how to set the default value of the dropdown to be D. 

 

I have tried

  • setting it to the Update value of the DataCard 'Letters'
  • DataCardValue118.Text
  • A Lookup direct from the datasource

All give the same error in the default property Im setting:

"The property expects record values, but theis rule produces incompatible text values"

 

Any ideas?

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

    What type of data source (SQL, SharePoint, etc) is being used for the form that the user is filling out and what is the column type in the data source?

  • BrianKennemer Profile Picture
    69 on at

    SharePoint

    The field in question is a Choice field and all values are strings less than 255 in length

     

    The field from which Im pulling the value that I want to be the default is a SharePoint single line text field with values that match exactly with values found in the Choice field above.

  • Verified answer
    Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    SharePoint is expecting a record with a special format. In the parent data card of the dropdown you need to set the default property to something like this:

     

    If(SharePointForm1.Mode = New, {
    '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    	Value:"Blue"}, 
    ThisItem.FavoriteColor)

    You will need to make some small changes so that the form (SharePointForm1), field value ("Blue") and ThisItem (FavoriteColor) to the correct named objects in your app. The code example only sets the default value if it is a new form otherwise it shows the value that was field.

     

  • BrianKennemer Profile Picture
    69 on at

    Awesome, Thanks very much

  • BrianKennemer Profile Picture
    69 on at

    @Jeff_Thorpe

    As a follow on to my previous question...

     

    So with your help I am able to set the defaults of of my fields based on 'profile' data I pulled from another datasource.

     

    Now Im working on updating that profile data with the currently selected values for those fields where I had set th defaults.

     

    So I have a button on a screen that updates the datasource using the current values. I would also like to take the current values for a few fields and update the fields in the user profile.

    When I try DataCardValue111.Text = DataCardValue61.Selected.Value it throws no error but also doesnt actually change the value of the data card for DataCardValue61.

     

    I know this is likely a stupidly simple thing Im missing but I have been looking at this long enough that I know Im missing something. 🙂

     

    Thanks

  • Verified answer
    Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    The "DataCardValue111.Text = DataCardValue61" is a comparison. Field values are declarative not imperative, so you can't set the value of an object from another object but instead you need to tell the object where to get the value.

    I don't quite understand the profile setup but you might want to think about storing the profile information into a collection then you could update the collection through the button and when the time comes you could save the profile collection with its updates back to the original data source.

  • Julian_Knight Profile Picture
    7 on at

    For goodness sake Microsoft! When will you learn how to keep things simple!!

     

    I thought that the purpose of PowerApps was that it should be a power use app creation tool and not need a higher degree in .NET in order to get anywhere.

     

    Smiley Mad

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 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard