Search code examples
azure-logic-appsdotliquid

dotLiquid syntax for inline IF..ELSE to Assign variable a Value


I want to assign my variable value based on following condition

var Result;
If(A==2)
   Result = A;
 else if(A>2)
    Result = A+2;

How can I write this in dotLiquid syntax for Logic Apps


Solution

  • The Logic App Liquid map can be something like this:

    {
        {% assign my_variable = content.a %}
    
        {% if my_variable == 2 %}
            "Result" : "{{ my_variable }}"
        {% elsif my_variable > 2 %}
            "Result" : "{{ my_variable | Plus: 2 }}"
        {% endif %}
    }