Logic Apps Best Practices, Tips, and Tricks: #54 Dynamically Initialize a Boolean Variable

  • Sandro Pereira
  • Jul 17, 2026
  • 4 min read

When working with Initialize variable actions in Azure Logic Apps, many developers assume that Boolean variables can only be assigned static values because the designer, at first glance, seems to restrict the Value field to True or False – which is not entirely true.

However, there is a useful tip that allows us to initialize a Boolean variable dynamically using expressions.

The Illusion of a Limitation

In the Logic Apps Designer, to initialize a Boolean variable using the Initialize variable action, you need to:

  • Name: set a variable name
  • Type: set type as Boolean
  • Value: and the value can be True or False
    • Normally, developers select one of the values by default: true or false
Initialize a Boolean Variable in Logic App

The designer doesn’t seem to provide an option to enter an expression directly. This often leads developers to initialize the variable with a default value and then immediately use a Set variable action afterward.

While functional, that approach adds unnecessary actions and complexity to the workflow.

Initialize a Boolean Variable

📝 One-Minute Brief

Many Azure Logic Apps developers believe Boolean variables can only be initialized with static True or False values. However, the designer allows custom expressions through the Enter custom value option, enabling dynamic Boolean initialization. This approach eliminates unnecessary Set Variable actions, simplifies workflows, improves readability, and results in cleaner, more maintainable Logic Apps implementations.

How to Dynamically Initialize a Boolean Variable

Many Azure Logic Apps developers assume Boolean variables can only be initialized with static values because the designer seems to restrict them to True or False. However, this is false. If you look at the picture below, you will see an option labeled Enter custom value.

Initialize a Boolean Variable with custom value

If you click on that option, then it will allow you to add expressions:

Initialize a Boolean Variable with expressions

And apply any kind of expression like:

if(equals(triggerBody()?['Origem'], 'Test'), true, false)
Initialize a Boolean Variable with expressions

Of course, after creating the variable, you can also switch to Code View and replace the static value with an expression:

{
   "name": "result",
   "type": "boolean",
    "value": "@if(equals(triggerBody()?['Origem'], 'Test'), true, false)"
}

In this case, we are checking if the Origem field in the request is equal to “Test“. If yes, set the variable to true. Otherwise, set it to false.

Now, when the workflow runs, the Boolean variable is initialized dynamically based on your business logic.

Why this approach is better

This simple approach is better than the traditional approach that I have encountered in many existing workflows because:

  • Eliminates an extra Set variable action.
    • Sometimes more than one Set variable action.
    • In some scenarios, it also eliminates the need for additional Condition actions that are used solely to determine the variable’s value.
Condition to set the variable
  • Keeps the workflow cleaner and easier to understand.
  • Reduces visual clutter in complex Logic Apps.
  • Evaluates the value immediately during initialization.
  • Makes the workflow slightly more efficient by reducing the number of actions.

Best Practice

Use this technique whenever the Boolean value can be determined at initialization time. Instead of:

  • Initialize Variable (False)
  • Set Variable (@equals(…))Show more lines

Prefer to use :

  • Initialize Variable (@equals(…))Show more lines

by entering a custom value or editing the workflow definition in Code View.

Pro Tip

In many cases, you don’t even need the if() statement because equals() already returns a Boolean value:

{
    "name": "result",
    "type": "boolean",
    "value": "@equals(triggerBody()?['Origem'], 'Test')"
}

This approach is cleaner and more readable, and it follows the principle of allowing Logic Apps expressions to return their native data types whenever possible.

If you enjoyed this tip, also check out my previous article on properly creating an Empty String Variable in Logic Apps.

I hope you find this helpful! If you liked the content or found it useful and want to help me write more, you can consider buying (or helping to buy) my son a Star Wars Lego set. 

Buy me a coffee
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top