Liquid Template for Log Apps

Format the date:-

"DocumentDate": "{{content.DocumentDate | Date:"yyyy-MM-dd HH:mm:ss" }}

Round the number:-

"Price": {{content.Price| Round: 2 }}

If condition to check field exists:-

{%- if lineItem.ItemId -%}

your logic goes here

{%- endif -%}

For Loop to produce an Array of Items:-

[

{%- for lineItem in content.Items -%}

your logic goes here

{%- if forloop.last == false -%},{%- endif -%}

 {%- endfor -%}

]

Nested For loop in Liquid Maps:-

The below code does nested for loop in the liquid template. It also looks up the data in another array and applies the logic conditionally.

{

"Items": [ {%- for lineItem in content.Items -%}

{%- if lineItem.ItemId -%} {

"ItemId":  "{{lineItem.ItemId}}",

                        {%- for pItem in content.PItems -%}

                        {%- if pItem.itemId ==  {{lineItem.ItemId}} -%}

                        "Price": {{pastelItem.recordValue | Round: 2 }}

                        {%- endif -%}

                        {%- endfor -%}

} {%- endif -%} {%- if forloop.last == false -%},{%- endif -%} {%- endfor -%}

        ]

}

Comments