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 / Facing issue while fet...
Power Pages
Unanswered

Facing issue while fetching data from multiple linked Entities using fetchxml (output Json)

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi Experts,

I am facing one issue while fetching data from multiple linked entities using fetchxml. It is giving me below error:

[
 Liquid error: Exception has been thrown by the target of an invocation.
 ]

Below is my Entities Relationship diagram:

 

Entities RelationshipEntities Relationship

 

And Below is my Fetchxml code, where I am trying to get the "ABC" Entities data by going Contact --> Population_Master -->ABC.

 

{% assign contactid = {{user.contactid}} %}

{% fetchxml feed %}
<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
 <entity name='contact'>
 <attribute name='fullname' />
 <attribute name='emailaddress1' />
 <attribute name='contactid' /> 
 
 <filter type='and'>
 <condition attribute='contactid' operator='eq' value='{{contactid}}' /> 
 </filter>
	
 <link-entity name='cre08_populationmaster' from='cre08_email' to='contactid' alias='populationlink'>
 <attribute name='cre08_globalid' />
 <attribute name='cre08_cedula' />
 
 </link-entity>
	
	 <link-entity name='cre08_abc' from='cre08_populationmaster' to='cre08_globalid' alias='ABClink'>
 <attribute name='cre08_abcid' />
 <attribute name='createdon' />
 
 </link-entity>
	
 </entity>
</fetch>

	
{% endfetchxml %}

 

 [
 {% for item in feed.results.entities %}
 {
 "Contact_id": "{{ item.contactid }}",
 "Contact_Name": "{{ item.fullname }}",
 "Contact_Email": "{{ item.emailaddress1 }}",
 "Population_id": "{{ item['populationlink.cre08_globalid']}}",
 "Population_Cedula": "{{ item['populationlink.cre08_cedula'] }}",
 "ABC_ID": "{{ item['ABClink.cre08_abcid'] }}",
		"ABC_CreatedOn": "{{ item['ABClink.createdon'] }}"
 
 }{% unless forloop.last %},{% endunless %}
 {% endfor %}
 ]
 

 

 

If you see the fetchxml code then you will find that "cre08_populationmaster" this is my logical entities name for "Population_Master" and I am trying to link other entities i.e ABC (logical name cre08_abc). but in my ABC entities my lookup field which relate the population master entities, the name is the same a "Population_Master" Entities i.e (cre08_populationmaster) (You can see in from of 2nd Linked Entities). cre08_globalid is a PK logical name in Population_Master Entities.

 

 

Is it fine to have the same entities name and lookup field name in other entities? not sure is that the reason of giving me the error?

 

Where I am doing a mistake? Is the above code is the correct way to fetch the data from multiple linked entities?

Below is the SQL logic same as fetchxml:

select a.fullname, a.emailaddress1, a.contactid, b.cre08_globalid, b.cre08_cedula, c.cre08_abcid, c.createdon
    from contact a join cre08_populationmaster b
    on a.contactid = b.cre08_email
     join cre08_abc c

    on c.cre08_populationmaster = b.cre08_globalid

 

Please help me with this issue.

 

Thanks,

Amit

Categories:
  • Christian Leverenz Profile Picture
    1,214 on at

    Hi @Anonymous  :

    i can not tell you the solution, but one link looks strange:

    <link-entity name='cre08_populationmaster' from='cre08_email' to='contactid' alias='populationlink'>

    is cre08_email a guid? strange name 🙂 - if not, this could be the reason.

    Usually i use the fetchxmltester in the xrmtoolbox to check the fetch and as a last step i put the variables in to get it working in portals...

    Hope this is a hint,

      Christian

  • Nicholas Hayduk Profile Picture
    174 Most Valuable Professional on at

    There is a good chance that you have the same problem as I did with multiple link-entity nodes for the same entity because of entity permissions:

     

    https://www.engineeredcode.com/blog/power-apps-portals-fetchxml-liquid-tag-and-entity-permissions

     

    Nick

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 18

#2
11manish Profile Picture

11manish 16 Super User 2026 Season 2

#3
anirudhev Profile Picture

anirudhev 4

Last 30 days Overall leaderboard