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
Community Champion
Community Champion

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

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.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (4,862)