cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
agneum
Advocate IV
Advocate IV

Get value from Lookup table?

Using SQL Server hosted on the cloud. I simply want to select an Id behind the scenes in a dropdown from a lookup table. For the user I want the name to be shown. If I set Items to '[dbo].[DepartmentLookup]' and Value to DepartmentId, I only get a list of numbers. If I select names, it is shown correctly for the user, but the values cannot be saved because they are not integers.

 

I'm looking for the follwoing, but for Powerapps + SQL Server:

https://powerapps.microsoft.com/en-us/blog/support-for-lookups/

 

And no, I'm not moving to Sharepoint lists in a million years.

5 REPLIES 5
Anonymous
Not applicable

Hi,


There are 2 ways of achieving this, that I know of.

The first one is to set the items on the drop down to be your table, and then in advance settings to chose what you want your display value to be. Here is an example of what I have:

dropdown.png

 

The second one which is more complicated, and not ideal as you query the database twice:

The way I am doing this is:

- on the drop down I set the items to be the display value you want, in your case the names.

- then I am using Patch to submit data I'm doing another lookup to get the id of the selected item. For example:

Patch([dbo].[Table], Defaults([dbo].[Table]), { 
	Id:LookUpp([dbo].[DepartmentLookup],dropdownn.Selected.Value = Name).Id,
	Name:dropdownn.Selected.Value
})

 

Hope this helps 🙂 

timl
Super User III
Super User III

Just to clarify, you just want to retrieve the selected value from a drop down control?

If this is the case, you can simply refer to the selected property of your drop down control.

 

Here's an example screenshot. In your case, you would set Items to '[dbo].[DepartmentLookup]', and value to field that you want to display in the drop down. 

 

ss1.PNG

 

To retrieve the selected value, you would use the syntax Dropdown1.Selected.DepartmentId.

 ss2.PNG

Thanks!

Problem is that I'm in EditForm. How does the datacard know what value to read? And still, it will complian that the string is not a correct value. 

timl
Super User III
Super User III

To configure the drop down to show the correct value when it loads, set the Default property of your drop down the following formula:
 

LookUp('[dbo].[DepartmentLookup]', DepartmentID = Parent.Default).Name

 

To configure the card so that it saves the DepartmentID value to your data source during an update,  select the parent card control, and set the Update property to the following formula:
 

YourDropdownBoxName.Selected.DepartmentID 

 
 These instructions assume that your card is unlocked, and is bound to the DepartmentID field.

 

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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