如何在Logic App中正确使用tolower()函数处理条件判断
tolower() in Logic Apps First, let's break down why you're hitting that InvalidTemplate error—usually it's because the expression syntax for tolower() isn't formatted correctly in your condition. Here's how to fix it step by step:
1. Correct Syntax for tolower() in Conditions
In Logic Apps, when using functions like tolower() in a condition, you need to wrap the entire expression in @{} (or just start with @ in the expression editor) to tell the engine it’s a dynamic expression, not plain text.
Common Mistake (Likely Causing Your Error)
If you tried entering something like this without proper expression wrapping:
tolower(triggerBody()?['YourInputField']) equals 'true'
Or forgot to reference the dynamic content path correctly, that would trigger a template validation error.
Proper Implementation
Here's the right way to set up the condition:
- In the left operand of your condition, switch from Dynamic content to the Expression tab.
- Enter your
tolower()expression, making sure to start with@and reference your input field correctly. For example:@tolower(triggerBody()?['YourInputField']) - Set the operator to is equal to, then in the right operand, type the lowercase value you want to compare against (like
trueorfalse).
2. Step-by-Step Workflow Example
Let’s say your input comes from an HTTP trigger with a field named IsLegit. Here’s how to build the case-insensitive check:
- Add a Condition action to your flow.
- Click the left input box, select the Expression tab.
- Paste this expression (adjust the field name to match your actual input):
@tolower(triggerBody()?['IsLegit']) - Set the operator to is equal to.
- In the right input box, type
true(all lowercase). - Now, no matter if the input is
TRUE,True, ortrue, it will match the condition.
3. Troubleshooting the InvalidTemplate Error
If you still see the error, double-check these details:
- Ensure you didn’t omit the
@symbol at the start of the expression—it’s mandatory for all Logic App expressions. - Verify the input field path is correct: use the dynamic content picker to select the field first, then wrap it in
tolower()to avoid typos. For example:@tolower(body('Get_Item')?['Status']) - Check for extra spaces or syntax typos in the expression (like missing parentheses or brackets).
This should resolve the template error and make your condition fully case-insensitive!
内容的提问来源于stack exchange,提问作者Beefcake

