Hi Peter
First, I would try to get rid of the TransactionScope wrapper. Or keep everything, from the Load method call and down, out of it.
I have had issues before when I tried something similar. Instead, I wrapped the logic in a try-catch block. In the catch block I log the exception, cancel the order, void the payment authorization, and so on.
Question: using the orderReference.OrderGroupId, can you actually find the purchase order in the preproduction database after the saving action, when the purchase order is NULL
?
Hi Stefan.
Thanks so much for taking a look at my question. I'm not sure if I'm looking at the correct table but I don't see a record for the purchase order in the [OrderGroup] table. I do see that the orderGroupId value for the purchase order was reserved because the ids of the records before and after the exception skip a number, but I don't see the record.
I'll talk to our implementation consultants about replacing the TransactionScope with a try-catch. I'm not sure why they used it since there isn't anything that can be cancelled by the user at this point.
Thanks,
Peter
The OrderGroup
table is where you should look in this case.
Good that you are getting the TransactionScope
refactored away. It doesn't make sense to wrap your logic in a transaction, as Episerver Commerce is robust enough without it.
I was wondering if anyone has encountered an issue where the purchase order from OrderRepository is NULL after calling SaveAsPurchaseOrder saving a cart about once or twice a day(we have about 200 orders per day).
It seems that every part of the process before the exception is working fine. We're not getting any exceptions or indication anything went wrong before the exception. For some bizzare reason the purchase order we get back is null after the cart is successfully saved.
Here is the code that does the order processing from the cart. The problem line is below the comment "Null reference exception is thrown here because purchase order is null"
So far I can only get this to happen in our preproduction or production environment so I wonder if there is some synchronization issues between the Episerver API and database in DXC.
Or maybe we're doing something not very efficient here? Also we're on Commerce 12.17.2 but it appears that we had the same issue before when we were on Commerce 11.
Thanks!