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