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