Skip to main content

Notifications

Announcements

No record found.

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 

  • 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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans