cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stapes
Post Prodigy
Post Prodigy

How do I prevent runtime errors from breaking my code?

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Mr-Dang-MSFT
Power Apps
Power Apps

Hi @stapes ,

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

v-xida-msft
Community Support
Community Support

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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-Canva...)

 

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.

Hi

 

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

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (88,492)