
Announcements
I'm trying to get some JSON data with FetchXML but running into an issue whenever I try to pull in data from lookup fields.
I have a location (cref9_location) that has a min and a max on the registration table (cref9_registration), and I want to list the min and max by location. It's an N:1 relationship (a registration can only be associated to one location, but one location can be associated to many registrations).
{% fetchxml feed %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="cref9_registration" >​
<attribute name="cref9_totalmin" />
<attribute name="cref9_totalmax" />
<link-entity name="cref9_location" to="cref9_location" from="cref9_name">
<attribute name="cref9_name" />
</link-entity>
</entity>
</fetch>
{% endfetchxml %}{
{% for item in feed.results.entities %}
"{{ item.cref9_name }}": {"min": "{{ item.cref9_totalmin }}", "max": "{{ item.cref9_totalmax }}"}
{% unless forloop.last %},{% endunless %}
{% endfor -%}}
I'm not 100% sure my link-entity is set up correctly: cref9_location is the name of the Table I'm targeting, and the column in cref9_registration with that lookup is also called cref9_location. cref9_name is in the cref9_location table. However, I've tried every imaginable combination of these values and I always get the error:
{ Liquid error: Exception has been thrown by the target of an invocation.}
The cref0_location table has Global permission set but I've also set it explicitly to all web roles. Just not sure what I'm doing wrong.
Hi @Anonymous
Probably you are missing intersect attribute in the link entity. I am not sure how you generated your FetchXML. I would strongly suggest you try the awesome tool "Fetch XML Builder"
https://www.xrmtoolbox.com/plugins/Cinteros.Xrm.FetchXmlBuilder/
You can use the XRM toolbox and install the Fetch XML Builder then add your entities and link to your other entities and get your FetchXML. There are some good videos out there on youtube.
Hint: Remember to set your Table permissions for all your entities
Hope it helps.
------------
If you like this post, give it a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users to find it.