Dear Community,
I have a challenge when using PostSave event functions: I cannot prevent save when some conditions are met.
As stated on the MS site, when the form OnPostSave event occurs, you can use the getEventArgs method of the execution context object to retrieve an object that contains methods you can use to manage the postsave event and those are: getEntityReference, getIsSaveSuccess and getSaveErrorInfo.
It means that even if we enable Async on Save in power app settings, we won't be able to benefit from executionContext.getEventArgs().preventDefault() and executionContext.getEventArgs().disableAsyncTimeout methods.
As the name says, the onPostSave is an event that occour after the save of a record. What you are looking for is the OnSave event, that occours before che save itself
Form OnSave event (Client API reference) in model-driven apps - Power Apps | Microsoft Learn\
In this event you can check for some condition and use the method executionContext.getEventArgs().preventDefault();
@Milosh I believe the PostSave event occurs just after the record has been saved. To use preventDefault your code needs to run pre-save (ie. By wiring up your event handler function to the onSave event configurable in the form designer)
WarrenBelz
109
Most Valuable Professional
Michael E. Gernaey
76
Super User 2025 Season 1
mmbr1606
71
Super User 2025 Season 1