In the latest episode of the "Low to Pro" series, Ace Phillips from Pragmatic Works explores how developers can master the OnSave behavior in Power Apps using JavaScript and custom code. This video addresses a common challenge: how to exert more control over form save processes, especially when built-in flows are not enough. By introducing advanced coding solutions into low-code environments, the tutorial empowers both new and experienced Power Apps users to elevate their forms’ data handling capabilities.
The episode begins by highlighting the limitations of traditional data joins and the need for more sophisticated event management within Power Apps. With new features introduced in 2024 and 2025, developers now have the tools to create more dynamic and reliable applications, ultimately bridging the gap between low-code and pro-code approaches.
A crucial part of mastering Power Apps forms lies in the correct setup of OnSave event handlers. The OnSave event, particularly relevant for model-driven apps and Dynamics 365 forms, is triggered just before data is saved. This timing allows developers to attach JavaScript functions for tasks such as validation, data modification, or even halting the save process if certain business rules are not met.
Since August 2024, Power Apps has supported asynchronous event handlers that return promises. This means developers can perform complex operations—like checking remote data or running multiple validations—before the save is finalized. However, balancing the power of these asynchronous handlers with performance is key, as the platform allocates up to 10 seconds per promise, and exceeding this can introduce delays or unexpected behavior.
Integrating custom JavaScript further expands what developers can accomplish during the save process. The video demonstrates how to use the saveEventArgs object, which provides methods like getSaveMode() to identify the type of save action being performed—such as "Save Only" versus "Save and Close". This distinction allows for conditional logic, so validations or custom actions only run when needed.
Moreover, the preventDefault() method enables developers to cancel a save operation if certain criteria are not met, ensuring that only valid data is stored. This feature is particularly useful for enforcing strict business rules and preventing incomplete or incorrect records from being saved. The challenge, however, lies in structuring this logic efficiently, as excessive or poorly organized code can lead to slower forms and a diminished user experience.
Another highlight of the episode is the use of post-save event handlers, such as addOnPostSave. These handlers are invoked after a record is successfully saved, making them ideal for triggering subsequent actions like navigation, workflow initiation, or additional data processing. By separating pre-save and post-save logic, developers gain more granular control over the user journey and system behavior.
Nonetheless, a key tradeoff exists: while post-save handlers enhance flexibility, they also introduce complexity in tracking application state and ensuring that all necessary actions are completed in the correct order. Developers must carefully manage event handler placement—distinguishing between OnLoad and OnSave events—to avoid unexpected results and maintain robust app performance.
As the video points out, consolidating multiple asynchronous operations into a single promise using Promise.all() can improve efficiency and reduce the risk of timeouts. This approach streamlines the handler logic and ensures that all required validations and data updates are completed before the save proceeds.
However, integrating custom code into a low-code platform like Power Apps is not without challenges. Developers must balance the need for advanced features with the inherent simplicity and maintainability of low-code solutions. Overly complex customizations can hinder future updates or make troubleshooting more difficult for less technical team members.
In summary, the advancements in Power Apps OnSave behavior—demonstrated by Pragmatic Works—offer developers a powerful toolkit for building robust, user-friendly business applications. By combining asynchronous event handling, conditional save logic, and advanced event APIs, developers can deliver more reliable and tailored form experiences.
While these capabilities unlock greater potential, the tradeoff between complexity and maintainability remains a central consideration. As organizations continue to embrace both low-code and pro-code strategies, mastering these techniques will be essential for achieving scalable, high-quality solutions in the Power Platform ecosystem.
Power Apps OnSave behavior JavaScript Power Apps custom code Power Apps tutorial mastering Power Apps low to pro Power Apps development tips advanced Power Apps techniques