cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mehardikdave
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
v-xiaochen-msft
Community Support
Community Support

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
v-xiaochen-msft
Community Support
Community Support

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.

That worked. Thanks

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,878)