7 Reasons Virtual Tables Aren’t Working in the Power Platform

3 Comments

In a previous post, I showed an example of how to set up Virtual Tables in the Microsoft Power Platform. In this post, I will look at potential issues you can run into using Virtual Tables with the OData provider, and how to resolve them.

Let’s take a look.

1. Fields are Not Mapped Properly

When you try to retrieve your virtual table data, you get the error “Entity could not be retrieved from data source. Please try again or contact your system administrator”:

Looking in the Plugin Trace Logs, we see the message “ExternalName is null or empty for attribute”:

To resolve this, we need to go to the fields on the entity and map the field using the external name. So in our case, the carl_name is not mapped, so let’s open the field:

Here we see the External Name field is currently blank. We will set it to the “Name”, which is the external OData name:

OData:

Repeat for each field in the data source.

2. Virtual Table External is Mapped to Wrong Place

When you retrieve data, you get the message “Exception type: Microsoft.Xrm.Sdk.Data.Exceptions.ExternalMetadataNotFoundException
Message: An external entity named ‘products’ wasn’t found. Entity Name: carl_virtualproduct”

The problem here is the virtual table is not mapped to the correct External names or the names are incorrect case. For example, below the External Name is product and products, which is incorrect from a case sensitive viewpoint:

We can see from the service metadata, the names should be capitalized:

3. Service is Mapped to Wrong Place

When you try to retrieve your virtual table data, you get the error “Exception type: Microsoft.OData.Client.DataServiceClientException
Message: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable”.

The possible reason here is in your Virtual Entity Data Source, you are not pointing to the root service, but rather an entity itself. E.g. below I am pointing to /products, which is incorrect – it should be just https://carlodatav4sample.azurewebsites.net/:

4. You Can’t Open a Record in D365

You can retrieve virtual table data, but when you click on the record in D365, it shows the error message “carl_virtualproduct With Id = ad725636-7d7a-4809-aded-eaf593ba8882 Does Not Exist”:

The problem here is we can’t retrieve a single record from the OData service from the URL like below –

https://carlodatav4sample.azurewebsites.net/products(ad725636-7d7a-4809-aded-eaf593ba8882)

We get the message “No HTTP resource was found that matches the request URI”.

To resolve this, ensure your OData service supports retrieving single records. As I have control over my OData service, I added the code:

5. Invalid Query Error

When you try to retrieve data, you get the message “Invalid Query. This query is not supported. Please update the query and try again. If the problem persists, contact your Microsoft Dynamics 365 administrator.”

The problem here is your OData source does not support $select and $filter:

E.g. https://carlodatav4sample.azurewebsites.net/products?$select=Name

If we browse to my service, we see an error thrown:

{“error”:{“code”:””,”message”:”The query specified in the URI is not valid. The property ‘Name’ cannot be used in the $select query option.”}}

To resolve this, add support for $select and $filter in your OData source. E.g.

6. Not Implemented Error

When you to to retrieve data, you get the message “Not Implemented”:

The issue here is the OData source has not been selected at the table/entity level:

Set this to the correct Data Source:

7. The OData Service is Expecting a Guid

If you get the error “Cannot convert a value of type ‘Edm.Int32’ to the expected target type ‘Edm.Guid’.” your service is probably returning an Int as the Id instead of a Guid. It needs to be a Guid:

 

THANKS FOR READING. BEFORE YOU LEAVE, I NEED YOUR HELP.
 

I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.

IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.

THANK YOU, AND LET'S KEEP LEARNING TOGETHER.

CARL

https://www.youtube.com/carldesouza

 

ABOUT CARL DE SOUZA

Carl de Souza is a developer and architect focusing on Microsoft Dynamics 365, Power BI, Azure, and AI.

carldesouza.comLinkedIn Twitter | YouTube

 

3 Responses to 7 Reasons Virtual Tables Aren’t Working in the Power Platform

  1. Hi Carl great article. One problem I’ve come across you haven’t mentioned is when you have a form pop up from a subgrid. I found that the record is displayed from the parent subgrid even without implementing retrieve single, which is useful because the parent table id is not provided in this query. However not all data is filled in – only the fields available in the subgrid view. I’m wondering why this is?

  2. Hi Carl, thank you for the article!

    In your experience are there any performance issues or issues that can arise from using an odata url to create a dataverse virtual table that contains potentially millions of records?

  3. Hi Carl, I ran into a virtual table exception today that I haven’t seen before: “Message: An external attribute named ‘CONTRACT_TERMINATION_DATE_TIME’ wasn’t found. Attribute Name: soa_terminationdate”.

    We had a working virtual table but needed to add a column, so we added the column to the OData service and verified that the column returns consistently. In D365, we added the column to the virtual table and published, but then that error started appearing… but intermittently!

    The only work-around was to create a new Virtual Table Data Source that pointed to the same OData endpoint and assign that data source to the virtual table. This somehow forced that new data source to use the newest OData metadata. Very frustrating, but at least there was a fix.

Leave a Reply

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