web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / If condition not worki...
Power Apps
Answered

If condition not working correctly

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Problem:

emails are being generated regardless of selection in a radio control.

What I need:

I'm only trying to send an email
IF
If(Radio3.Selected.Value = "Completed – Sent Email" 
any other selection made , no email gets generated ?

 

Code below:

SubmitForm(Form2);
If(Radio3.Selected.Value = "Completed – Sent Email",
Office365Outlook.SendEmailV2( LookUp(Sales_Commission_Category,
Topics = DataCardValue20.Text &&
Subtopic = DataCardValue21.Text,
Email
),// Text(ToEMailVar.Email),
"Work Request: " &varRecord.ID & "",
"Sales Intake Response " & " "
& "<br>Request Id: " & varRecord.ID
& "" & "<br>Requestor: " & DataCardValue14.Text & ""
& "<br>Requestor_User_Id: " & DataCardValue16.Text & ""
& "<br>Impacted_Team_Member: " & DataCardValue17.Text & ""
& "<br>Impacted_Team_Member_Racfid: " & DataCardValue18.Text & ""
& "<br>Topic: " & DataCardValue20.Text & "" & "<br>Sub_Topic: "
& DataCardValue21.Text & "" & "<br>Question: "
& DataCardValue31.Text & "<br> " & "<br>Response: "
& DataCardValue23.Text & "<br> <br> " & "<br>Click Here to Respond <a href='https://apps.powerapps.com/play/b932r453-230895212121731498? tenantId=48dssssss1dcb6-bccc-4365-a3432c7f-b9ss37a7fssssss7fd71&FormID=" & varRecord.ID & "'> Link </a>", {Cc:DataCardValue24.Text} )
; UpdateContext({Popup_Email_Sent_r: true}), Refresh(eMail_Flow_Intake_Information) ) ;
If(Radio3.Selected.Value = "Completed – No Email",UpdateContext({Popup_Email_Sent_r: true}))

 

Thanks

Dave

Categories:
I have the same question (0)
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymous 

    You might consider the following.

    Set the OnSelect of your submit button to the following:

    SubmitForm(Form2)

    Then in the OnSuccess action of Form2, the following Formula:

    If(Radio3.Selected.Value = "Completed – Sent Email",
     Office365Outlook.SendEmailV2(
     LookUp(Sales_Commission_Category, Topics = DataCardValue20.Text && Subtopic = DataCardValue21.Text, Email),
     "Work Request: " & varRecord.ID,
     "Sales Intake Response<br>
     Request Id: " & varRecord.ID & "<br>
     Requestor: " & DataCardValue14.Text & "<br>
     Requestor_User_Id: " & DataCardValue16.Text & "<br>
     Impacted_Team_Member: " & DataCardValue17.Text & "<br>
     Impacted_Team_Member_Racfid: " & DataCardValue18.Text & "<br>
     Topic: " & DataCardValue20.Text & "<br>
     Sub_Topic: " & DataCardValue21.Text & "<br>
     Question: " & DataCardValue31.Text & "<br><br>
     Response: " & DataCardValue23.Text & "<br><br> 
     <br>Click Here to Respond <a href='https://apps.powerapps.com/play/b932r453-230895212121731498? tenantId=48dssssss1dcb6-bccc-4365-a3432c7f-b9ss37a7fssssss7fd71&FormID=" & varRecord.ID & "'> Link </a>", 
     {Cc:DataCardValue24.Text} 
     )
    );
    
    UpdateContext({Popup_Email_Sent_r: true}), 
    

     

    In this scenario, you are only sending (if you need to) an email based on the success of the record being submitted.  With your last formula, an email would be sent even if the submit failed.

     

    Also, you might find yourself in trouble with the references to the DataCardValues in your email.  Depending on your form mode, those values may no longer exist, you should refer to the LastSubmit property of your Form in the formula.  

    I do not know the exact names of your columns in your data source, but here is an example of that:

    With({submitted:Form2.LastSubmit},
     If(Radio3.Selected.Value = "Completed – Sent Email",
     Office365Outlook.SendEmailV2(
     LookUp(Sales_Commission_Category, Topics = submitted.Topic && Subtopic = submitted.Subtopic, Email),
     "Work Request: " & submitted.ID,
     "Sales Intake Response<br>
     Request Id: " & submitted.ID & "<br>
     Requestor: " & submitted.Requestor & "<br>
     Requestor_User_Id: " & submitted.Requestor_User_Id & "<br>
     Impacted_Team_Member: " & submitted.Impacted_Team_Member & "<br>
     Impacted_Team_Member_Racfid: " & submitted.Impacted_Team_Member_Racfid & "<br>
     Topic: " & submitted.Topic & "<br>
     Sub_Topic: " & submitted.SubTopic & "<br>
     Question: " & submitted.Question & "<br><br>
     Response: " & submitted.Response & "<br><br> 
     <br>Click Here to Respond <a href='https://apps.powerapps.com/play/b932r453-230895212121731498? tenantId=48dssssss1dcb6-bccc-4365-a3432c7f-b9ss37a7fssssss7fd71&FormID=" & submitted.ID & "'> Link </a>", 
     {Cc:submitted.CC} 
     )
     )
    );
    
    UpdateContext({Popup_Email_Sent_r: true}), 
    

     

    Also, final note, there is no need to Refresh your datasource to get the data you just submitted...it will already be there.  

     

    I hope this is helpful for you.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 296 Most Valuable Professional

#2
11manish Profile Picture

11manish 224

#3
Valantis Profile Picture

Valantis 181

Last 30 days Overall leaderboard