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 / Using Notify Function ...
Power Apps
Answered

Using Notify Function Within An IF Statement

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I am using the Notify() function to deliver either a Success OR Error message based on an IF statement which runs after a Patch() function is executed. The patch function is working 100% of the time so far, yet I never see the Success msg per the Notify() in the IF statement. What am I missing?

 

// Execute Patch function
Set( varReturnedRecord, Patch( 'DB-Src', ThisItem, { Status: dropdownStatusAssignWriter.Selected, Comments: txtCommentsAssignWriter.Text } ) );

// Check IF Patch function was successful
If( varReturnedRecord.ID = 0,
  // ******* ERROR **************** //
  Office365.SendEmail(
  "name@domain.com;",
  "Project X: A PATCH ERROR HAS OCCURRED DURING SAVE OPERATION",
  User().FullName & " (" & User().Email & ") was performing the save operation on file '" & ThisItem.File & "' when the error   occurred."
  );
  // Alert User - Populate msg var with error message
  Notify( "ERROR: Your updates to file '" & ThisItem.File & "' were NOT successfully saved.", Error ),


 // ******* ELSE - SUCCESS ******* //
 Office365.SendEmail("name@domain.com", "Project X: " & User().FullName & " Has Successfully Updated Info for '" & locThisItemFileAssignWriter & "'", htmlEmailAssignWriter.HtmlText, {IsHtml: true});
  // Alert User - Populate msg var with success message
  Notify( "Your updates to file '" & ThisItem.File & "' were successfully saved.", Success );

  Refresh('DB-Src');
);

Categories:
  • Verified answer
    yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hi @Anonymous 

     

    Can you try to update the expressions as:
    Set(varReturnedRecord, Patch( 'DB-Src', ThisItem, { Status: dropdownStatusAssignWriter.Selected, Comments: txtCommentsAssignWriter.Text } ) ); Refresh( 'DB-Src')

    If( !(varReturnedRecord.ID in 'DB-Src'.ID) ,
    Office365.SendEmail("name@domain.com;","Project X: A PATCH ERROR HAS OCCURRED DURING SAVE OPERATION",
    User().FullName & "(" & User().Email & ") was performing the save operation on file '" & ThisItem.File & "' when the error occurred."
    );
    Notify( "ERROR: Your updates to file '" & ThisItem.File & "' were NOT successfully saved.", NotificationType.Error ),
    Office365.SendEmail("name@domain.com", "Project X: " & User().FullName & " Has Successfully Updated Info for '" & locThisItemFileAssignWriter & "'", htmlEmailAssignWriter.HtmlText, {IsHtml: true});
    Notify( "Your updates to file '" & ThisItem.File & "' were successfully saved.", NotificationType.Success )
    );

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thank you @yashag2255 for the solution - it works!  I have two followup questions below. 

    Why didn't my original code work? What was the issue?

    What is the difference between these two? 
    Notify( "Error msg text", Error) VS. Notify( "Error msg text", NotificationType.Error)


  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hey @Anonymous 

     

    One of the reason why your code didn't work could be because of the comments. I have faced this issue myself.

    Notify( "Error msg text", Error) VS. Notify( "Error msg text", NotificationType.Error)
    Error is a different keyword which might not be suitable for this case. You have to properly refer to the arguments in all the expressions.

     

    Hope this Helps!

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    @yashag2255 - Thank you for the explanation and for taking the time to respond!

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 July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 394 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 324 Most Valuable Professional

Last 30 days Overall leaderboard