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

Notifications

Announcements

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 265

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 759 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 310 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 228

Last 30 days Overall leaderboard