web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Validate data after saved
Power Apps
Unanswered

Validate data after saved

(0) ShareShare
ReportReport
Posted on by 269

Hello everyone,

 

I don't know whether this is possible or not, but in Model-driven, can we validate data after it is being saved ? So lets say I save a record (new record), I need the form to be validated again, before user accidentally close the form (without save again)

 

I found this function, but to be honest I don't have any background of CRM nor JavaScript, as I come from D365 Finance & Operation, so I don't how to use it. It is called PostSave ->

https://docs.microsoft.com/en-us/powerapps/developer/model-driven-apps/clientapi/reference/events/postsave

 

Can someone give me a guidance over here ?

 

Thanks in advance.

I have the same question (0)
  • cchannon Profile Picture
    4,702 Moderator on at

    That is precisely the correct event to attach to. The addOnPostSave function allows you to tell Dataverse "hey, after a save is completed, I want you to do this thing over here." so the way you use it is you build a function that does the validation you want, then during the onLoad event you call this addOnPostSave function and pass it the function you want it to run in the post save event. Let me give you an example:

     

    function onLoad(executionContext) {
    	var formContext = executionContext.getFormContext();
    	formContext.data.entity.addOnPostSave(doMyValidation);
    }
    
    function doMyValidation(executionContext)
    {
    	if (1 != 2) {
    		console.log("Of course 1 is not equal to 2!")
    	}
    }

    So first, you register the function onLoad on the form during the onLoad event. Easy. Then when the form opens, it runs this code. The code tells the form that whenever the postSave event happens, it should call the function "doMyValidation". Then, when the user hits save during the post event the form calls doMyValidation.

     

    Now, all that is easy enough, but you will have to then write your validation logic, and there's not much I can do to help you with that. What I can tell you is that if you've gotten this far you're really close and you just need to trust that the documentation page where you found addOnPostSave is the right place to look for everything else you need for validation like checking the value of fields and updating them if necessary.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 101 Most Valuable Professional

#2
Haque Profile Picture

Haque 81

#3
VASANTH KUMAR BALMADI Profile Picture

VASANTH KUMAR BALMADI 70

Last 30 days Overall leaderboard