web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How to Retrieve a Row ...
Power Pages
Suggested Answer

How to Retrieve a Row from a Virtual Table by External Primary Key

(0) ShareShare
ReportReport
Posted on by 4
Hi All,
 
I'm building a custom component that uses a few virtual tables built from SharePoint lists. Due to the nature of the data in the tables, I can't use linked entities. For each row in table A, I would process a string from a specific column to retrieve an external primary key (aka ID in SharePoint lists). Then, I want to retrieve the row in table B that has this external primary key and get data from the other columns of that row and display it. However, I'm having some trouble getting the other columns as they show up as blank. This is the code that I have so far:
 
{% fetchxml queryA%}
<fetch mapping='logical' distinct='true'>
  <entity name='msdyn_tablea'>
    <attribute name='msdyn_stringcolumnwithid' />
  </entity>
</fetch>
{% endfetchxml %}

{% fetchxml queryB %}
<fetch mapping="logical">
  <entity name="msdyn_tableb">
    <attribute name="msdyn_externalprimarykey" />
    <attribute name="msdyn_column1" />
    <attribute name="msdyn_column2" />
  </entity>
</fetch>
{% endfetchxml %}

{% for row in queryA.results.entities %}
    {% assign updatedId = row.msdyn_stringcolumnwithid| split: ": " | last | replace: ";", "" | strip %}
    {% assign formattedId = updatedId | decimal %}
    {% assign filterResults = queryB.results.entities | where: "msdyn_externalprimarykey", formattedId %}
    {% assign matchedRow = filterResults [0] %}

    <p>Number of entries found: {{ filterResults.size }}</p>
    <p>Column 1: {{ matchedRow.msdyn_column1 }}</p>
    <p>Column 2: {{ matchedRow.msdyn_column2 }}</p>
{% endfor %}
 
 
The filterResults.size will return 1. I have to format updatedId to a decimal as the external primary key is set to decimal by default and I could not change that upon the virtual table creation. However, when I test with a number directly, it is able to filter and return the data from the other 2 columns. I have searched through many articles and solutions within this forum itself and could not find a good solution to my problem so any help would be highly appreciated. Thanks in advance.
Categories:
I have the same question (0)
  • Suggested answer
    Suriyanarayanan V Profile Picture
    201 on at

    When working with virtual tables, especially those backed by SharePoint lists, the behaviour you’re seeing is expected. The reason filterResults.size returns 1 but the other columns are blank is because:

    Liquid filtering does not perform type‑coercion on virtual table attributes.

    Even though you converted the ID to a decimal, the value inside the virtual table entity is not a true decimal, but a string representation coming from the SharePoint connector.

    So the comparison:

    | where: "msdyn_externalprimarykey", formattedId

     

    matches the row by key, but the returned entity object does not hydrate the other attributes because the filter is not executed server‑side — it’s a Liquid in‑memory filter.

    This is a known limitation with virtual tables + Liquid.

    Why the attributes are blank

    Virtual tables only return full attribute data when the FetchXML query itself includes a filter that matches the row.
    When you filter after the query using Liquid:

    queryB.results.entities | where: ...

     

    …the platform does not re‑query the virtual table provider.
    It simply filters the already‑returned rows, and virtual table rows often contain only the primary key unless the provider returns full data.

    This is why:

    • filterResults.size is correct

    • matchedRow.msdyn_column1 and matchedRow.msdyn_column2 are blank

    The attributes were never populated.

    The fix: Apply the filter in FetchXML, not in Liquid

    You need to query table B per row using FetchXML with a filter, like:

    {% fetchxml queryB %}
    <fetch mapping="logical">
      <entity name="msdyn_tableb">
        <attribute name="msdyn_externalprimarykey" />
        <attribute name="msdyn_column1" />
        <attribute name="msdyn_column2" />
        <filter>
          <condition attribute="msdyn_externalprimarykey" operator="eq" value="{{ formattedId }}" />
        </filter>
      </entity>
    </fetch>
    {% endfetchxml %}
     

    This forces Dataverse to call the virtual table provider and return the full row, including all attributes.

    Important note

    This means you will need to run the FetchXML for table B inside the loop for each row in table A.
    Yes, it’s more expensive, but it is the only reliable way to retrieve full attribute data from virtual tables in Power Pages.

    Summary

    • Liquid filtering does not hydrate virtual table attributes.

    • Virtual table rows only return full data when filtered in FetchXML, not in Liquid.

    • Move the filter into the FetchXML query for table B.

    • Run the FetchXML inside the loop for each ID.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
11manish Profile Picture

11manish 38

#2
Valantis Profile Picture

Valantis 36

#3
omkarsupreme Profile Picture

omkarsupreme 24

Last 30 days Overall leaderboard