Hello,
I have a problem deleting an sales order record. I get the following error message:
System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Sql error: Generic SQL error. CRM ErrorCode: -2147204784 Sql ErrorCode: -2146232060 Sql Number: 547
The 547 means that there are dependent data and cannot be deleted.
I have also partially analyzed the problem.
A short description of what I do:
I have an asynchronous workflow that updates a record and performs a few calculations on the record and also creates dependent data.
If the workflow has not run yet and I delete the record, it can happen that the deletion and the calculation run at the same time.
I have logged which stages are called in which order:
DELETE => 10
UPDATE => 10
UPDATE => 20
UPDATE => 40
As you can see, first the PreValidation-Delete is called, then the Update-Stages, after that the error message appears.
This means that before the PreOperation-Delete is called, the update creates new data records.
Does anyone have any ideo how to lock the record, so that the update is not executed?
Thank you