In Canvas App, when multiple Patch statements are written to submit data across different tables or lists, there may be a problem if any of these fail during the operation. In this scenario, users often want to rollback the insert for the other data sources as well. While SQL server provides the option to Rollback Transaction, Canvas App does not have this option in Power Fx.
A workaround example is presented with an online shopping Canvas App where buyers can submit their Product details and modify the price later. To keep the historical pricing data, two SharePoint lists are used: 'Online Shopping' and 'Price History'. On button click, the app updates or inserts into the 'Online Shopping' list, obtains the ID of that record, and then inserts it into the 'Price History' list along with the date and price.
To facilitate error handling in a Canvas App, the Preview Feature 'Formula Level Error Management' must be enabled in Settings>Upcoming Features>Preview.
The management of errors in a Canvas App is pivotal to ensure smooth operations, especially when dealing with Patch statements across multiple platforms. A typical approach includes error messages in cases of failed patches, effectively guiding the user in resolving and preventing further complications. This feature is enabled through the 'Formula Level Error Management' preview. With the importance that the technology industry places on data integrity and error handling, seeking and implementing solutions like this one enables Canvas Apps to tackle challenges smartly.
Canvas App enables users to rollback all patches from a button click if an error occurs for one. This is possible by using the option to Rollback Transaction in SQL server that discards all the data updates inside a transaction. However, in Canvas App, there is no such straight forward option. To handle this situation, there is a workaround. For example, in an Online Shopping Canvas App, the buyers submit their Product details. The Price history of the Product is recorded in two SharePoint Lists - Online Shopping and Price History. To enable Error handling in a Canvas App, users must turn on the Preview Feature Formula Level Error Management from Settings>Upcoming Features>Preview. The OnSelect Property of the Submit Button Click contains a code to Patch the Online Shopping list. If an error occurs in this Patch statement, the Notify message will appear and the data will not be inserted into the Price History list. If the first Patch is successful, but the second Patch fails, then it will delete the corresponding entry from the first list and show an error message.
microsoft canvas app, microsoft power fx, rollback transaction, online shopping list, price history list, preview feature, formula level error management