cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
bolin-stratus
Level: Powered On

Using Notify Function Within An IF Statement

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');
);

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Using Notify Function Within An IF Statement

Hi @bolin-stratus 

 

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!

View solution in original post

4 REPLIES 4
Dual Super User
Dual Super User

Re: Using Notify Function Within An IF Statement

Hi @bolin-stratus 

 

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!

View solution in original post

bolin-stratus
Level: Powered On

Re: Using Notify Function Within An IF Statement

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)


Dual Super User
Dual Super User

Re: Using Notify Function Within An IF Statement

Hey @bolin-stratus 

 

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!

bolin-stratus
Level: Powered On

Re: Using Notify Function Within An IF Statement

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

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (2,242)