cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted

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

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?

Brian Kennemer
Projectified Consulting
www.projectified.com
brian.kennemer@projectified.com
2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

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

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.

 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

Super User
Super User

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

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.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

7 REPLIES 7
Super User
Super User

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

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?



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

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

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.

Brian Kennemer
Projectified Consulting
www.projectified.com
brian.kennemer@projectified.com
Super User
Super User

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

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.

 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

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

Awesome, Thanks very much

Brian Kennemer
Projectified Consulting
www.projectified.com
brian.kennemer@projectified.com

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

@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

Brian Kennemer
Projectified Consulting
www.projectified.com
brian.kennemer@projectified.com
Super User
Super User

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

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.



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

View solution in original post

Julian_Knight
Level: Power Up

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

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 145 members 4,789 guests
Please welcome our newest community members: