Retrieve CRM Records using Liquid Fetchxml in Dynamics 365 Portals

In Dynamics 365 portal , to read the products based on the price list using Fetchxml as below

FetchXML: fetchxml is a liquid object which will used to read the CRM records at server side

 

                {% fetchxml products %}
                <fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
                    <entity name='productpricelevel'>
                        <attribute name='productid' />
                        <attribute name='uomid' />
                        <attribute name='pricingmethodcode' />
                        <attribute name='amount' />
                        <attribute name='productnumber' />
                        <attribute name='transactioncurrencyid' />
                        <filter type="and">
                            <filter type='and'>
                                <condition attribute='pricelevelid' operator='eq' uitype='pricelevel' value='{{priceid}}' />
                            </filter>
                        </filter>
                        <link-entity name='product' from='productid' to='productid' visible='false' link-type='inner' alias='pro'>
                            <attribute name='name' />                               
                            <attribute name='description' />
                            <attribute name='productnumber' />
                            <attribute name='productid' />
                            <attribute name="producttypecode" />                               
                        </link-entity>                           
                    </entity>
                </fetch>
                {% endfetchxml %}
 {% if products.results.entities.size > 0 %}
                    {% for item in products.results.entities %}
{%endfor%}
{%endif%}

Get the Query string parameter value in Liquid script

To read the query string parameter in Dynamics 365 portal using liquid script can be done using request liquid object.

This request object contains the information about the current HTTP request.

if your URL contains a parameter named as RecID

in the Liquid script you can read the value as below

{% assign RecordId=request.params[‘RecID’] %}

we can use the RecordId value in your HTML/Java script by using the below syntax

{{RecordId}}

Fulfill Order Request in MS CRM

Using the below c# code we can Fulfill the order entity record in MS CRM

private void FullfilOrder(Guid ordid,IOrganizationService service)
{
             int newStatus = 100001;       
            Entity oclose = new Entity()
        {
            LogicalName = "orderclose",

        };
        oclose["salesorderid"] = new EntityReference("salesorder", ordid);
        var request = new FulfillSalesOrderRequest
        {
            OrderClose=oclose,
            Status = new OptionSetValue(newStatus)
        };

        service.Execute(request);
}