cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DM2
Frequent Visitor

forms datacards and dropdowns - trick or OK

The following works, but it feels a bit like it does so by accident.  Is there a better (more robust) way to do this?

 

DM2_1-1616776373915.png

 

The default of the datacardvalue is set to "dropdown.selectedtext.value"

 

And the default of the dropdown is set to  "thisitem.datacardvalue"  (ie whatever comes from the datasource)

 

It SEEMS to work a treat. When the form is opened the dropdown is set to the value retrieved from the datasource (via a gallery control to select the individual record). If you select a different dropdown value the datacardvalue is set to the dropdown and copied back to the datasource when you submitform()

 

Just feels wrong tho. Feels like it relies on some hidden accident of sequencing - almost like a happy race condition.

 

(The datacardvalue data source is a sharepoint list single line field. The dropdown choices are hard-coded into the dropdown items property.  I know that is a bad place to start from but it's what I have to work with!)

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@DM2 

What you are doing is what is called an Allowed Values control type.

In the future (or now), when you add the Field to your form, you can at that point (or any point unless you've unlocked the card) change its control type to "Allowed Value".  Once you have done that, your datacard will now have an AllowedValues property on it.  On that property you can set your "hard-coded" items for the dropdown.  Everything else will be done for you automatically.

 

So, either do the above, or for what you have now, your DataCard Default property should be set to : ThisItem.yourFIeldName

The Default of your dropdown should be : Parent.Default

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@DM2 

What you are doing is what is called an Allowed Values control type.

In the future (or now), when you add the Field to your form, you can at that point (or any point unless you've unlocked the card) change its control type to "Allowed Value".  Once you have done that, your datacard will now have an AllowedValues property on it.  On that property you can set your "hard-coded" items for the dropdown.  Everything else will be done for you automatically.

 

So, either do the above, or for what you have now, your DataCard Default property should be set to : ThisItem.yourFIeldName

The Default of your dropdown should be : Parent.Default

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

DM2
Frequent Visitor

Sure is. Thanks @RandyHayes 

RandyHayes
Super User
Super User

@DM2 

Just remember - if you want Dropdowns for Text fields in your form, the field chooser will automatically convert it to that without ever having to unlock the datacard and add other controls yourself.  Will save you some time and frustration!

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
DM2
Frequent Visitor

Thanks @RandyHayes . I spent some time looking at forms in a bit more detail last night. When I get a few hours I'll re-write this app "properly".  That's the challenge with low-code - it's too easy to get things nearly, but not quite, right 🙂   Thanks again.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,209)