cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MattMcQ
Level: Powered On

Dropdown based on ID field

I'm not sure why I'm struggling with this so much but I'm trying to do a simple dropdown control based on an ID field stored in the datasource. In this case I have a "request" table and a "statuscode" table. The request table has a statusID field which is linked to the statuscode table. Let's say there are two values for status code, "1=Open, 2=Closed". I added the code below to the default property but it doesn't appear to work. I have a record that is closed but the dropdown shows open. 

 

This should be simple and something I will need to do often if I am going to work with database tables which often just store the ID of a foreign key instead of the display text. 

 

If(EditForm1.Mode = FormMode.New, LookUp(StatusTable, 1 = StatusID, Status), LookUp(StatusTable, Parent.Default = StatusID, Status))
1 ACCEPTED SOLUTION

Accepted Solutions
iotc
Level: Powered On

Re: Dropdown based on ID field

Hi, this is how I do it with a combobox control called fkSex_dd

 

dd.png

View solution in original post

2 REPLIES 2
iotc
Level: Powered On

Re: Dropdown based on ID field

Hi, this is how I do it with a combobox control called fkSex_dd

 

dd.png

View solution in original post

MattMcQ
Level: Powered On

Re: Dropdown based on ID field

Turns out to be user error. My formula for the lookup on the default in the drop down was not using the ID field from the supporting table. I was using StatusID instead of StatusCodeID. Normally I would use the exact same name for the fields but I wonder if that is a good idea. If both tables had "StatusID" then how would the lookup know which to use? If I get the time I should try a test and see what happens. Looking at your example I assume that is partially why have a "fk" prefix on your main table when looking to store the ID from a foreign table.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 69 members 3,585 guests
Recent signins:
Please welcome our newest community members: