Below is the code for retrieving Data from CRM using FetchXML and Liquid Code:
{% fetchxml products %}
<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
<entity name="arp_product">
<attribute name="arp_name" />
<attribute name="arp_productid" />
<order attribute="arp_name" descending="false" />
<filter type="and">
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="arp_parentproduct" operator="eq" value="{{request.params.id}}" />
<condition attribute="arp_producttype" operator="eq" uitype="ema_producttype" value="{xxxxxxxx-xxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" />
</filter>
</entity>
</fetch>
{% endfetchxml %}
{% if products.results.entities.size > 0 %}
{
{%assign size = products.results.entities.size %}
"results":[
{% for product in products.results.entities %}
{
"ProductId": "{{arp.ema_productid}}",
"ProductNo": "{{arp.ema_name}}"
}
{% unless forloop.last %},{% endunless %}
{% endfor %}
],
"length" : "{{size}}"
}
{% else %}
No data found.
{% endif %}

No comments:
Post a Comment