cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kazashimo
New Member

Creating an 'if' expression in Power Automate

Hello,

 

Wondering if anyone could advise please.

 

I’m attempting to create an ‘if’ expression in the body of one of my flows that handles data from Forms. I need the flow to only include an answer (in an email that is sent to the help desk), only if another question is answered ‘yes’, for example:

 

Forms question 1: Do you wish to remote into your PC?

Forms question 2 (will only show if question 1 is answered with ‘yes’): Enter the host name of your computer

 

I need the flow to only add the hostname (from question 2) (into the email that is sent) if question 1 is answered with ‘yes’.

 

For testing purposes, I have tried the following expression for the first part (to check if the answer is ‘yes’ or ‘no’):

 

if(triggerBody()?['rcee21e8ca796498da50d37db60e7bd92'],'rdp required','rdp not required')

 

but I see the following error when testing:

 

InvalidTemplate. Unable to process template language expressions in action 'Send_an_email_(V2)' inputs at line '1' and column '2843': '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.'.

 

My idea is that the hostname (from question 2) will only be stated in the email if question 1 is answers with ‘yes’.

 

Any help would be appreciated.

 

Regards.

1 REPLY 1
ChristianAbata
Super User
Super User

hi @Kazashimo  what you nedd is add a correct condition see this examples

 

If you want to compare with a custom value use equals.

 

if(equals(body('Get_response_details')?['r80d9e12f9d7c429ea192e3bceac26133'],'CustomValue'),'Exist','Not Exist')
 
See this expresion:  equals(body('Get_response_details')?['r80d9e12f9d7c429ea192e3bceac26133'],'CustomValue') is a true of false expresion.
 
so if the answer that users sends is equals to a custom value then write exist or if not write Not exist.
 
see this other example to see if a value is empty.
 
if(empty(body('Get_response_details')?['r80d9e12f9d7c429ea192e3bceac26133'])),'Empty','Not Empty')


Did I answer your question? Please consider to Mark
my post as a solution! to guide others :winking_face:

Proud to be a Flownaut!


If you want you can follow me at www.christianabata.com Quieres contenido en español? Síguenos en Power Automate LA

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events happening this month - don't miss out!

 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

Users online (2,492)