Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Portal - To read json using LIQUID

  • 1.  Portal - To read json using LIQUID

    Posted 17 days ago

    I am doing a Fetch XML on the portal page using LIQUID, and receiving a json output on the same page as a result.

    I need to read this json instantly when I receive it and do certain things on the html.

    For example:
    {
    "TrustId": "32E18BFF-6795-EA11-A811-000D3A4A17C4",
    "schools": [
         {      "guid": "52G18FFF-3795-FA11-N811-000E3A4A17C5",
                "name": "abc school",
                 "Area": 2
         },
         {       "guid": "62G18FFF-3795-FA11-N811-000E3A4A17C5",
                "name": "def school",
                 "Area": 3
         }
     ]}

    I know we can make our web page as JSON mime type and can get it using jquery or javascript from the URL.

    But can this be done directly on a page to access JSON object as mentioned in example above?

    Kind regards,



    ------------------------------
    Jimmy mcad
    ------------------------------
    Academy - Online Interactive Learning from Experts


  • 2.  RE: Portal - To read json using LIQUID

    TOP CONTRIBUTOR
    Posted 16 days ago
    Is there a reason why you can't just use the Liquid capability to loop through the records returned by the FetchXML?  Check this blog post for an example:

    http://dyn365apps.com/2017/09/14/dynamics-365-portals-liquid-templates-part-3-retrieve-data-using-fetchxml/

    The relevant code is this part:

    {% for result in my_query.results.entities %}
          <div name="content" style="padding: 15px 30px 0 0; clear: both;">
            <h2> {{ result.fullname | escape }} </h2>
          	<div name="image" style="width: 300px; float: left; padding: 0 0 0 15px;">
          	  <img src={{ result.websiteurl | escape }} height="150" width="150"  >
          	</div>        		
          	<div name="main-content" style="margin-left: 300px; max-width: 800px;">
          		<p> {{ result.description | escape }} </p>
          		<br />        			
          	</div>        		
          	<div class="clear"></div>
          </div> 
      {% endfor %}​


    ------------------------------
    Chris Harrington
    Solutions Architect
    PowerObjects, an HCL Company
    ------------------------------

    Academy - Online Interactive Learning from Experts


If you've found this thread useful, dive deeper into User Group community content by role