I can’t close a sales order from my plugin and I’m just getting an error...
"Need to start a transaction before commit"
My plugin:
- Creates a new sales order from an opportunity
- Checks if there are any orders already, if so; copy the old products to the new order if they don't exist in the new order.
- Close the old order as canceled.This doesn’t work. I’m just getting this “Need to start a transaction before commit”
Any ideas?
I've found this on google but I can't get around it... :-(
Link 1:
http://sliong.wordpress.com/2012/06/08/crm-2011-need-to-start-a-transaction-before-commit-fault-exception/
Link 2:
http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/ca1301ca-cef9-4940-9cb4-e968641199f6
My code:
The plugin is triggerd on the message "Win"
private bool FullfillAndCloseSalesOrder(IOrganizationService service, Guid _orderId) { try { var request = new FulfillSalesOrderRequest { OrderClose = new OrderClose { SalesOrderId = new EntityReference { LogicalName = SalesOrder.EntityLogicalName, Id = _orderId } }, Status = new OptionSetValue(2) }; service.Execute(request); return true; } catch(Exception ex) { throw new Exception("Unable to close the orignal order! Err: " + ex.Message); } }