Spurious "need to start a transaction before commit" error RRS feed

  • Question

  • I have two custom entities in my system a "leave request" and a "leave request history". The leave request history includes a lookup to the leave request and the leave request includes a lookup to System user as the employee, the employee is distinct from the record owner. All very simple so I can create a leave request for myself and then create a leave request history record to say it was granted. But if I create a leave request for another user and then try to create a leave request history record to say that was granted if fails with the following error;

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Need to start a transaction before commitDetail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" />
      <Message>Need to start a transaction before commit</Message>
      <InnerFault i:nil="true" />
      <TraceText i:nil="true" />


    LeaveRequest {Owner = Adam, Employee = Adam, Id = 1 }
    LeaveRequestHistory {Owner = Adam, LeaveRequest = 1, Action = Grant }

    works but

    LeaveRequest {Owner = Adam, Employee = Bob, Id = 2 }
    LeaveRequestHistory {Owner = Adam, LeaveRequest = 2, Action = Grant }

    Generates a "need to start a transaction before commit" error when the leave request history is created. What is happening here?

    • Edited by J N Brand Friday, October 11, 2013 11:04 PM
    Friday, October 11, 2013 10:49 PM

All replies

  • Hi,

    This tends to be caused when you update the target entity in a plugin using service.Update. Do you have any plugins registered?

    Scott Durow
    Blog www.develop1.net    Follow Me
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Friday, October 11, 2013 11:06 PM
  • I have plugins registered to the create event on that entity but they are asynchronous and the error occurs at the user interface on create. I originally saw the error from a silverlight app but in debugging it I have now found I can create the error just by creating that entity through the 'New' button from a CRM list of leave request histories so it's not a coding error it's something inside CRM itself.

    Friday, October 11, 2013 11:10 PM
  • I have a solution.

    One plug in had erroneously been registered as a synchronous rather than asynchronous event. That plug in contains an error in an unrelated event (sending an email about what had been done) which was not critical the the event creation. When registered as a synchronous event and the plug in failed it triggered a roll back which deleted the created entity which had triggered that event. Just to compound issues CRM then reports an error message which has nothing to do with either email failing or rolling back.

    So the effect appeared to be that no entity was created and CRM failed before creating the entity reporting a missing begin transaction. What is really happening was that the begin transaction was submitted as was the commit, a non critical email error killed a plugin, CRM destroys validly created user data which is unrelated to the error (which alone is enough to warrant throwing mickeysoft crm in the bin!) and then reports something else entirely! (don't you just love the accuracy of CRM error messages)

    • Edited by J N Brand Monday, October 28, 2013 6:41 PM
    Monday, October 14, 2013 9:47 AM