Below is the code to retrieve Data from CRM using Liquid Code only without using FetchXML:
{
{% if request.params.id %}
{% assign prd = entities['arp_product'][request.params.id] %} // Get Product Id from URL
{% if prd.arp_productcontactid.id %} // if it has id
{% assign contact = entities['contact'][{{prd.arp_productcontactid.id}}] %} // fetching contact from the contact entity by passing product id
{% assign prcontact = contact.email %} // fetching email from the contact
{% endif %}
{% if prd.arp_rapporteurid.id %}
{% assign contact1 = entities['contact'][{{prd.arp_rapporteurid.id}}] %}
{% assign prrapporter = contact1.email %}
{% endif %}
{% if prd.arp_corapporteurid.id %}
{% assign contact2 = entities['contact'][{{arp.ema_corapporteurid.id}}] %}
{% assign prcorapporter = contact2.email %}
{% endif %}
// Returning these values in the JSON Format
"prodid": "{{request.params.id}}",
"prcontact":"{{prcontact}}",
"prrapporter":"{{prrapporter}}",
"prcorapporter":"{{prcorapporter}}"
{% endif %}
}
No comments:
Post a Comment