Quantcast
Channel: Forum CRM Development
Viewing all articles
Browse latest Browse all 1000

CRM 2011 C# - Cant' fullfill/close/cancel an sale order

$
0
0

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:

  1. Creates a new sales order from an opportunity
  2. 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.
  3. 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);
            }
        }


Viewing all articles
Browse latest Browse all 1000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>