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 / How do I prevent runti...
Power Apps
Answered

How do I prevent runtime errors from breaking my code?

(0) ShareShare
ReportReport
Posted on by 894

My App is updating a Database when OnChange is activated:

 

     Patch('[dbo].[TBL_JS_GOODS_IN_CONTROLSHEET]', First(Filter('[dbo].[TBL_JS_GOODS_IN_CONTROLSHEET]',ID=SelectedItem.ID)),{DateDelivered:dtDateDelivered.SelectedDate, UpdatedBy:User().FullName,UpdatedOn: Now()});Set(Updated, true)

 

It all worked fine until I added a Trigger to the SQL Table being updated.

Now, my statement is flagged in red, with the error message:

GoodsInV2 Screen4 - Inspection Tab - trigger error.jpg

 

I have now removed the Trigger from the DB, but my app is still broken. The error message persists, and my commands are still marked as invalid?

Categories:
I have the same question (0)
  • Mr-Dang-MSFT Profile Picture
    Microsoft Employee on at

    Hi @stapes ,

    Have you tried removing and re-adding the SQL table to the app?

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

    Hi @stapes ,

    Based on the issue that you mentioned, I think you have some misunderstanding on the known limits with SQL Server connector. Insert and update to a table does not work if you have a SQL server side Trigger defined on the table. Please check the following known limits with SQL Server connector:

    https://docs.microsoft.com/en-us/connectors/sql/#known-issues-and-limitations

     

    As an fixed solution, please consider remove the SQL Table connection from your app, then re-create a new connection to your SQL Table from your app, then try your formula again, check if the issue is solved.

     

    In addition, please also consider modify your Patch formula as below:

    Patch(
     '[dbo].[TBL_JS_GOODS_IN_CONTROLSHEET]', 
     LookUp('[dbo].[TBL_JS_GOODS_IN_CONTROLSHEET]',ID = SelectedItem.ID), 
     {
     DateDelivered: dtDateDelivered.SelectedDate, 
     UpdatedBy: User().FullName,
     UpdatedOn: Now()
     }
    );
    Set(Updated, true)

     

    Best regards,

  • stapes Profile Picture
    894 on at

    That is not what I am asking here. I am asking how I prevent these issues from breaking the code on the app screen, not about the trigger issue specifically.

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @stapes ,

    Currently, within PowerApps, there is no direct way or functions supported to prevent these issues from breaking the code.

     

    As an fixed solution, please consider remove the Trigger from your SQL Table, then re-create a new connection to your SQL Table from your app, then re-type your formula within the OnSelect property of the button.

     

    Best regards,

  • stapes Profile Picture
    894 on at

    I have already removed the trigger from the table - as suggested above. It still was not the question I was asking in this post. We covered that issue in my previous post (https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/SQL-Triggers-not-working-with-Canvas-App/m-p/415425#M122717)

     

    What I am asking is how these errors can be prevented from breaking the canvas app in the edit screen. Instead I have to delete & re add the formulas to remove the errors before it will run again. The formulas remain unchanged.

  • stapes Profile Picture
    894 on at

    Hi

     

    Thanks for the heads up on the Lookup command. Much faster!

  • AchatesChen Profile Picture
    51 on at

    Is there a solution now for this issue? I have to use trigger, so this issue makes the app impossible to be completed. This is really ridiculous! I was using MySQL and all were ok. Now I need to migrate to MSSQL. I thought it is Microsoft product so should have better compatibility, but now...

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

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard