cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Expressions using "if" that worked last week are broken now.

I spent countless hours last week getting a flow to work using some variables, but I log in this week and see that they aren't working anymore. I gett the following error:

 

"InvalidTemplate. Unable to process template language expressions in action 'Manager_Approval_Email' inputs at line '1' and column '2559': 'The template language function 'if' expects its first parameter to be of type boolean. The provided value is of type 'String'. Please see https://aka.ms/logicexpressions#if for usage details.'"

 

This is the expression that's failing:

 

if(variables('Reports to Shayna'),'shayna@studiofathom.com', body('Get_manager_(V2)')?['mail'])
It's my understanding that it should work like this: If "Reports to Shayna" is True, use shayna@studiofathom.com. If it is False, get the email from Get_manager_(V2) and insert it here.
 
Why is this not working anymore?
1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

That's pretty much how I have it set up.

 

My 'Reports to Shayna' variable is reading out "False" in this test, so shouldn't it be using 'test2@companyname.com' as the result?

 

I was able to get it to work by using this:

if(equals(variables('reports'),"True'),'test1@company.com','test2@company.com')

View solution in original post

4 REPLIES 4
v-yamao-msft
Community Support
Community Support

Hi @Anonymous,

 

It seems that you have set Variables in your flow.

 

I made a test on my side with the similar code to check if the email has an attachment, if yes, sent email to email address1, if no, sent to the sender.

 

It works fine without error.

 

The code I am using is:

if(variables('reports'),’test1@company.com,’test2@companyname.com’)

 

please check the following screenshot:

2.PNG

 

Have you modified the flow with the variables? Please try to recreate the flow to see if it will wrok.

 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello, @Anonymous!

Have you had an opportunity to apply @v-yamao-msft‘s recommendation to adapt your Flow? If yes, and you find that solution to be satisfactory, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify!


Thank you for being an active member of the Flow Community!

-Gabriel
Flow Community Manager

- Gabriel
Community Manager
Power Automate | Power Virtual Agents
Super User Program Manager



Anonymous
Not applicable

That's pretty much how I have it set up.

 

My 'Reports to Shayna' variable is reading out "False" in this test, so shouldn't it be using 'test2@companyname.com' as the result?

 

I was able to get it to work by using this:

if(equals(variables('reports'),"True'),'test1@company.com','test2@company.com')

crf200
Advocate IV
Advocate IV

Is there a way to run the 'IF' function on a boolean without initializing a Variable function. I'm running into an issue initializing a variable within an 'Apply to each'.

 

I'm trying to establish a line of text being added to a field into an output based on an previous boolean. Here is what I'm trying

 

if(equals(items('ATE')?['field'], 'true'), "RBC: ","")

 

Where if the boolean reads true then it adds the string "RBC: " to the output.

 

There are some pretty complex 'Apply to each' functions at this point in the flow and variables aren't an option.

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (1,198)