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

Notifications

Announcements

Community site session details

Community site session details

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

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

(0) ShareShare
ReportReport
Posted on by
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)

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 63 Super User 2025 Season 2

#2
Lucas001 Profile Picture

Lucas001 25 Super User 2025 Season 2

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 16 Most Valuable Professional

Last 30 days Overall leaderboard