Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Problem with a simple If statement

Posted on by 359

@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

  • Verified answer
    bobgodin Profile Picture
    bobgodin 359 on at
    Re: Problem with a simple If statement

    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

  • bobgodin Profile Picture
    bobgodin 359 on at
    Re: Problem with a simple If statement

    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!

  • Re: Problem with a simple If statement

    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
    bobgodin 359 on at
    Re: Problem with a simple If statement

    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

     
     
  • Re: Problem with a simple If statement

    Hi @bobgodin ,

     

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

     

     Best Regards,
    Tina

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,297

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,890

Leaderboard