Adventures with Dataverse: Virtual Tables and Look Up Columns

Recently, I was playing around with Dataverse and Virtual Tables, specifically with the AdventureWorksLT database in Azure SQL.

Note, you can easily import this data by creating a new SQL Database in Azure.

Figure 1 – Use existing AdventureWorks data

In the AdventureWorksLT database there is a table called SalesLT.SalesOrderHeader that has a foreign key relationship to two other tables, SalesLT.Customer and SalesLT.Address.

Those were the tables I imported as virtual tables.

After creating the virtual tables I noticed that the foreign key columns came over as values, the relationships were lost! 🫨

I thought I might get lucky, and they would come over as Lookup columns, but alas, they didn’t. 😞

Figure 2 – No primary name values showing, just the underlying value

From Power Apps Studio I thought might be able to add a relationship and use the existing columns but doesn’t seem to be a way to do that. While I can create a new column, that doesn’t really help me out, especially if I want to persist changes back to SQL.

Figure 3 – Cannot choose from existing columns for a new relationship

Maybe there is something I can do in the classic portal? 🤔

Buckle up!

To get to the classic portal, from my Solution, I clicked on Objects, then the Ellipsis (…) and lastly, Switch to classic.

Figure 4 – Switching to classic

I clicked the SalesLT.SalesOrderHeader entity.

Note, Tables and Entities are the same thing, Table is the modern term, and Entities the legacy term.

Figure 5 – Sales Order entity

I clicked Fields, then adw_customerid field, and then Delete. I did need to confirm the deletion.

Figure 6 – Deleting the CustomerID column

Once the column was deleted, I clicked on New.

I set Display Name to CustomerID, which automatically populated Name and External Name.

I then set Field Requirement to Business Required.

Now for the secret sauce! 🪄

I set Data Type to Lookup and then Target Record Type to SalesLT.Customer.

I clicked Save and Close.

Figure 7 – New CustomerID column as a Lookup column

I switched back to the Power Apps Portal, selected Tables, and then the SalesLT.SalesOrderHeader table.

My CustomerID now displayed the Primary Name column from the SalesLT.Customer table instead of the actual value. w00t! w00t! 🥳

Figure 8 – Lookup Primary Name column is displayed

If I add that field to a Form it will now display as a Lookup control. 👏

Figure 9 – Form displays a Lookup control

Not super revolutionary, but a nice to know should you ever need to do it in the future!


Discover more from Matt Ruma

Subscribe to get the latest posts sent to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *