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

How to retrieve dropdown selected value having data source as Lookup table

Hi Team,

 

I have a simple form with three text fields and a DropDown control. The issue that I face is as below.

1) The Datasource of the whole form is from a single table named Milestone.

2) The data source for the dropdown is a field (Project_Id) that is type Lookup and mapped to another table named Project (Foreign Key). 

 

Below is the table Milestone where Project_Id is a Lookup field

mehardikdave_1-1611236955477.png

Below is the Project table having Projectid as Unique field.

mehardikdave_0-1611236851092.png

 

To give more context, below are the details of the Project table with important fields been highlighted

mehardikdave_2-1611237362056.png

 

 

3) When I run the screen, I can see actual values of the Project names in the dropdown. Till now everything works fine.

4) What I wanted is, when I select any value from the dropdown, I want the selected text to be copied to a TextBox which I made visible false so as to capture the selected values from the DropDown. My only reason to have an extra textbox is to capture the value of the dropdown. If you guys can suggest a better option then nothing like that.

 

What steps I did:

1) In the OnChange event of the DropDown, I wrote below UpdateContext code, which is not working

UpdateContext({selectedTrade:Lookup([@Projects], Community=drpProjects.Selected.Value, Name))

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft
Microsoft

Hi @mehardikdave ,

 

Could you tell me:

What’s the data type of Community column? Is it a text column?

Do you want to display the contents of the Milestone table in the dropdown control and the name of the Project table in the label control?

 

I assume:

You want to display the value of the name column of the Milestone table in the dropdown control.

You want to display the value of the Name column of the Project table in the label control.

 

I did a test for you

1\ This is my test Milestone table and Project table.

v-xiaochen-msft_0-1611308327881.png

 

v-xiaochen-msft_1-1611308327882.png

 

 

2\ Add a dropdown control and set its Items property to:

Milestones

 

Set the onchange property of the dropdown control to:

UpdateContext({selectedTrade: LookUp(Milestones,Milestone=Dropdown1.Selected.Milestone).Project_Id.Name}) 

//  Dropdown1 is the name of my dropdown control.

//  Milestone is Unique Identifier.

 

3\ Add a label control land set its Text property to:

selectedTrade

 

4\ The result is as follows:

 MMM.gif

 

Best Regards,

Wearsky

If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

2 REPLIES 2
Microsoft
Microsoft

Hi @mehardikdave ,

 

Could you tell me:

What’s the data type of Community column? Is it a text column?

Do you want to display the contents of the Milestone table in the dropdown control and the name of the Project table in the label control?

 

I assume:

You want to display the value of the name column of the Milestone table in the dropdown control.

You want to display the value of the Name column of the Project table in the label control.

 

I did a test for you

1\ This is my test Milestone table and Project table.

v-xiaochen-msft_0-1611308327881.png

 

v-xiaochen-msft_1-1611308327882.png

 

 

2\ Add a dropdown control and set its Items property to:

Milestones

 

Set the onchange property of the dropdown control to:

UpdateContext({selectedTrade: LookUp(Milestones,Milestone=Dropdown1.Selected.Milestone).Project_Id.Name}) 

//  Dropdown1 is the name of my dropdown control.

//  Milestone is Unique Identifier.

 

3\ Add a label control land set its Text property to:

selectedTrade

 

4\ The result is as follows:

 MMM.gif

 

Best Regards,

Wearsky

If my post helps, then please consider Accept it as the solution to help others. Thanks.

View solution in original post

That worked. Thanks

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (20,575)