cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
randalloglesby
Helper I
Helper I

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

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 @randalloglesby,

 

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, @randalloglesby!

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



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

crf200
Advocate III
Advocate III

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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Users online (20,523)