cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BO55VXR
Advocate II
Advocate II

Setting value of Dropdown with "Table" datasource

Hi all,

 

I have a Dropdown on my form with the following properties.

 

ItemsTable({Text: "Examination", Val: "X"}, {Text: "Expiry", Val: "E"}, {Text:"Observation", Val: "O"})
ValueText
DefaulteditRecord.EventType
ResetresetForm

 

I have a gallery of items which the user can select which should then show the appropriate value of the drop down, but it is not. The code for the OnSelect() of the gallery is

 

Set(editRecord,{ID: ThisItem.Id, EventType: ThisItem.EventType);

// Force update of form controls

Set(resetForm, true);

Set(resetForm, false);

 

The EventType property is E, X or O, as per the table of items but the Dropdown does not change from the first value in its Items list, irrespective of he value of the EventType field. I can see that the field is changing as per selecting each item as I have a (temporary) label showing the value.

 

I surley think it's me doing something stupid ... I just cannot see what.

1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@BO55VXR 

First things first, you must be using a ComboBox as opposed to a Dropdown here because your table has 2 columns: Text and Value.  There's a difference in how these controls work so the distinction is important.

 

For ComboBoxes you need to define a record as the default.  I get the feeling that editRecord.EventType only supplies a text value.  This will not work.

 

You'll need to put your table of options into a collection.  Do this in the OnVisible property of the screen.

 

ClearCollect(colOptions, Table({Text: "Examination", Val: "X"}, {Text: "Expiry", Val: "E"}, {Text:"Observation", Val: "O"}))

 

Then change the Items property of your ComboBox 

 

colOptions

 

Finally, use a LOOKUP function in the Default property of the ComboBox to retrieve a record value instead of a text value like you were doing previously.

 

LookUp(colOptions, Val = editRecord.EventType)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

 

View solution in original post

2 REPLIES 2
mdevaney
Super User
Super User

@BO55VXR 

First things first, you must be using a ComboBox as opposed to a Dropdown here because your table has 2 columns: Text and Value.  There's a difference in how these controls work so the distinction is important.

 

For ComboBoxes you need to define a record as the default.  I get the feeling that editRecord.EventType only supplies a text value.  This will not work.

 

You'll need to put your table of options into a collection.  Do this in the OnVisible property of the screen.

 

ClearCollect(colOptions, Table({Text: "Examination", Val: "X"}, {Text: "Expiry", Val: "E"}, {Text:"Observation", Val: "O"}))

 

Then change the Items property of your ComboBox 

 

colOptions

 

Finally, use a LOOKUP function in the Default property of the ComboBox to retrieve a record value instead of a text value like you were doing previously.

 

LookUp(colOptions, Val = editRecord.EventType)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

 

 

Smashing ... Thanks

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,897)