DEV Community

Leonard Soetedjo
Leonard Soetedjo

Posted on

5 4

Liquid template in Logic App

I was testing out Shopify liquid template to perform XML to XML/JSON data transformation. Liquid template is one of the templating tool mentioned in Microsoft's website to perform data transformation in Logic App (the other tool being the venerable XSLT).

I've not used XSLT before, but comparing to liquid template, the latter seems more friendly. As such, I embarked on using liquid template for my research.

Below are the 2 observations I found, and the workaround I need to do to fulfill the task on hand.

  1. Syntax differences between liquid and dotliquid (used by Microsoft):
    a. Capitalisation of first letter, i.e. Append instead of append.
    b. Different naming, i.e. DividedBy instead of divided_by

    The problem for syntax differences is that there's no error. The script just run successfully, but the filter functions are not executed 🙄.

  2. Unable to differentiate single child node vs. list of child nodes. To give an example, below are 2 valid snippets that can be interpreted differently.

    Snippet 1

    <order>
        <orderItem>
            <itemName>Item 1</itemName>
        </orderItem>
    </order>
    

    Snippet 2

    <order>
        <orderItem>
            <itemName>Item 1</itemName>
        </orderItem>
        <orderItem>
            <itemName>Item 2</itemName>
        </orderItem>
    </order>
    

    The first snippet interprets order as an object containing orderItem. On the other hand, the second snippet interprets order as an _array _of `orderItem 😅

    Fortunately, Microsoft has JSONArrayFor. Using JSONArrayFor instead of For loop, we're able to force order to be treated as an array regardless of the number of orderItem insider order.

Image of Docusign

Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay