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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Problem with a simple ...
Power Apps
Answered

Problem with a simple If statement

(0) ShareShare
ReportReport
Posted on by 380

@WarrenBelz @RandyHayes I have a simple If statement which I know evaluates to true yet the Office365Outlook.SendEmailV2 function refuses to run 😞

 

This is what is not working - i.e no email is generated: DataCardValue8 is a Toggle and DataCardValue139 is a ComboBox

If(
 DataCardValue8.Value = true && DataCardValue139.Selected.Value = "Sport and Recreation",
Office365Outlook.SendEmailV2(
 varRecord.supervisor & ";" & "secondemail@qld.qld.gov.au; thirdemail@qld.qld.gov.au",
 varRecord.firstname & " " & varRecord.surname & " has submitted a " & DataCardValue87.Selected.Value & " Report ID " & varRecord.ID & " on behalf of " & varRecord.'PI-firstname' & " " & varRecord.'PI-surname',
 If(
 DataCardValue87.Selected.Value = "Hazard",
 HtmlTextforHazard.HtmlText,
 HtmlTextforIncident.HtmlText
 ),
 {
 Cc: varRecord.manager & ";" & varRecord.'email-address',
 Importance: "High"
 }
 ),"")

I know the If statement evaluates to true cos I have put the following code on the Text property of a button:

If(DataCardValue8.Value = true && DataCardValue139.Selected.Value = "Sport and Recreation" ,"Yes", "No") and the Text display of the button is Yes.

 

If I change the If statement to the following, it works perfectly

If(
 1=1,
Office365Outlook.SendEmailV2(
 varRecord.supervisor & ";" & "secondemail@qld.qld.gov.au; thirdemail@qld.qld.gov.au",
 varRecord.firstname & " " & varRecord.surname & " has submitted a " & DataCardValue87.Selected.Value & " Report ID " & varRecord.ID & " on behalf of " & varRecord.'PI-firstname' & " " & varRecord.'PI-surname',
 If(
 DataCardValue87.Selected.Value = "Hazard",
 HtmlTextforHazard.HtmlText,
 HtmlTextforIncident.HtmlText
 ),
 {
 Cc: varRecord.manager & ";" & varRecord.'email-address',
 Importance: "High"
 }
 ),"")

any assistance greatly appreciated

Categories:
I have the same question (0)
  • v-hanytian-msft Profile Picture
    Microsoft Employee on at

    Hi @bobgodin ,

     

    May I Ask what is the error Message shows on the App?

     

     Best Regards,
    Tina

  • bobgodin Profile Picture
    380 on at

    Hi @v-hanytian-msft there is no error message - the SendEmail function just doesn't run - it's like it doesn't evaluate the If statement correctly

     
     
  • v-hanytian-msft Profile Picture
    Microsoft Employee on at

    Hi @bobgodin ,

     

    We recommend that you fill in only one condition to filter which condition is having the problem.

    For example:

    If(
     DataCardValue8.Value = true,
    Office365Outlook.SendEmailV2(
     varRecord.supervisor & ";" & "secondemail@qld.qld.gov.au; thirdemail@qld.qld.gov.au",
     varRecord.firstname & " " & varRecord.surname & " has submitted a " & DataCardValue87.Selected.Value & " Report ID " & varRecord.ID & " on behalf of " & varRecord.'PI-firstname' & " " & varRecord.'PI-surname',
     If(
     DataCardValue87.Selected.Value = "Hazard",
     HtmlTextforHazard.HtmlText,
     HtmlTextforIncident.HtmlText
     ),
     {
     Cc: varRecord.manager & ";" & varRecord.'email-address',
     Importance: "High"
     }
     ),"")

     

    Best Regards,
    Tina

  • bobgodin Profile Picture
    380 on at

    Hi @v-hanytian-msft tried with the 1st one - didn't work, then tried with the 2nd one - didn't work either - I am stumped!

  • Verified answer
    bobgodin Profile Picture
    380 on at

    I have solved the mystery I changed my If statement to:

    If(
    varRecord.'Business Unit'.Value = "Sport and Recreation" && varRecord.'sport-facility'=true,

    and Powerapps is happy

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Kalathiya Profile Picture

Kalathiya 445

#2
WarrenBelz Profile Picture

WarrenBelz 386 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 321 Super User 2025 Season 2

Last 30 days Overall leaderboard