cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stapes
Impactful Individual
Impactful Individual

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

7 REPLIES 7
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.
stapes
Impactful Individual
Impactful Individual

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.
stapes
Impactful Individual
Impactful Individual

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.

stapes
Impactful Individual
Impactful Individual

Hi

 

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

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

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (2,302)