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 / Patch Function Error H...
Power Apps
Unanswered

Patch Function Error Handling to SQL Server

(0) ShareShare
ReportReport
Posted on by 46

Hi All,

 

Have what I hope is a simple question and looking forward to any advice that can be offered.

 

I am using the Patch function in an App that pushes data to a SQL Server.  I have error handling in place but I'm struggling with how to handle a duplicate error in the app.  Right now I have the following in place:

 

// Check for Errors after the + sign is clicked
If(
IsEmpty(Errors('C21-BudVer')),
// Successful Entry
Notify(
"Version Saved Successfully",
NotificationType.Success
),
// Failed Entry
Notify(
"Error Occurred Version Not Saved",
NotificationType.Error
)
)

 

On the SQL end I have controls in place to prevent duplicate entries, so if a user tries to send a duplicate value I think that the "Error Occurred Version Not Saved" message should appear, but that isn't what is happening.

 

Instead when a User enters a duplicate value, the following message appears "Network Error When Using Patch Function:  The requested operation is invalid."

 

How do I handle this error so that the user knows that their entry failed because they have entered a duplicate item?  It seems to me like the error is happening before the Failed Entry trigger is happening.

 

Any advice would be most appreciated!

Categories:
I have the same question (1)
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @More2Learn,

     

    I handle custom errors with the IfError() or If(IsError()) formulas, this might also be useful in your case.

    You would wrap these functions around your Patch() statement in order to catch the error and throw a custom notification instead. Below I will show the architecture for both options which might be applicable to your case:

     

    IfError():

    IfError(
     Patch(
     Datasource,
     Defaults(Datasource),
     {ColumnName: Value}
     );
     Notify(
     "Version Saved Successfully",
     NotificationType.Success
     ),
     //Should above fail, run code below
     Notify(
     "Error Occurred Version Not Saved",
     NotificationType.Error
     )
    )

     

    If() & IsError():

    If(
     //Run code and return true if it failed
     IsError(
     Patch(
     Datasource,
     Defaults(Datasource),
     {ColumnName: Value}
     )
     ),
     //Run if failed
     Notify(
     "Error Occurred Version Not Saved",
     NotificationType.Error
     ),
     //Run if successful
     Notify(
     "Version Saved Successfully",
     NotificationType.Success
     )
    );
    

     

    If this solves your question, would you be so kind as to accept it as a solution.

    Thanks!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,027

#2
Valantis Profile Picture

Valantis 644

#3
11manish Profile Picture

11manish 626

Last 30 days Overall leaderboard