SBarnes wrote:We have a customer that is getting double up on web hooks for sales order namely you get a create and update when an order is created.
I believe the issue is arising because there is a customisation that asks the user on the creation of the order if they want to automatically print the picking slip.
The only way I can think of to short circuit this would be to set a flag in the generic object list on the print event of the sales order or in the customisation code and then short circuit the event firing that sends the hook and remove the flag and bail out before sending the hook.
Is there an easier way to overcome this?
Webhooks are sent on the occurrence of the SaveEnd event of a business logic object - so in your case it sounds like your sales order is being saved twice - which actually is needed, because the for the Crystal report to print it needs to have the data saved in the table - that's the first save - and when you print anything it adds a print log entry for the sales order and saves the sales order, which is how the print log entry is saved - so that's the second save.
Technically, the webhook is being sent twice and rightly so - it should be sent each time the subscribed resource (sales orders in this case) changes.
If you do as you propose and prevent the sending of the second webhook which occurs when the print log is updated - then you'll lose getting webhooks when the user loads an existing order and prints something which triggers a save - which may not be important to you but is worth considering. Be aware also that throwing client cancelled exceptions or similar within the business logic will result in the client (Jiwa application) not responding properly - it won't receive the necessary event to trigger a re-read after save.
If you can devise a solution which works, then great - but if not we'll need a sample plugin which exhibits the issue - then we can work through finding a suitable solution.