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

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Is the javascript PostSave event fired multiple times?

(0) ShareShare
ReportReport
Posted on by 54

Hello, 

We have a custom react ordering system made that uses javascript on the form to handle the creation of queue items for each saved record. I'm encountering some weird behaviour and I'm not sure what is causing it.

The javascript code is attached in it's own file, inserting code wouldn't work for me some how.

[View:/cfs-file/__key/communityserver-discussions-components-files/761/OrderingPostSaveEvent.js:194:152]

Context: 

My ordering system has two buttons for saving - 'save as draft' and 'send order'. Both these buttons triggers the save event (formContext.data.entity.save()) and does some other operations as well, which are irrelevant and won't be the cause of this. The queue item is only created when the 'send order' button is clicked. 

When I first save a record as draft, and then send the order - two queue items are created. If I send the order without saving as draft only one queue item is created. This is consistent.
I just can't figure out why this is happening. I'm quite sure there isn't a race condition in my code, and my assumption is that the postsave event isn't added multiple times to the form somehow.. 

Have anyone encountered this before? Or can see a solution to my problem?

Please don't hesitate to ask for additional information.

Regards, 
Marius 

I have the same question (0)
  • Mariusssf Profile Picture
    54 on at
    RE: Is the javascript PostSave event fired multiple times?

    Some how it seems that the PostSave event fired twice. Added a removeOnPostSave(postSaveFunction) in the onLoad function before addOnPostSave, which has fixed the problem. Makes no sense that the PostSave event doubles up on a normal save event through formcontext..

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 109

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 109

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 77 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans