Wednesday, December 9, 2015

Crm Exception: Message: Generic SQL error., ErrorCode: -2147204784, InnerException: Microsoft.Crm.CrmException: Generic SQL error. ---> System.Data.SqlClient.SqlException: Transaction was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

Crm Exception: Message: Generic SQL error., ErrorCode: -2147204784, InnerException: Microsoft.Crm.CrmException: Generic SQL error. ---> System.Data.SqlClient.SqlException: Transaction was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

If you have any doubt in the post please post comments. I will try to solve your problem with in a day.

The problem was that as it looped through the quoteproducts returned which I was updating, there was a lock on subsequent records as the first one was being updated. I put a half-second delay in between each update and now it works just fine.
     
            for (var i = 0; i < retrievedData.length; i++) {
                var objQuoteDetail= {};
                objQuoteDetail.new_DeliveryTerms = "FWG";

                var quoteDetailGUID = "{" + retrievedData[i].QuoteDetailId + "}";

                SDK.REST.updateRecord(quoteDetailGUID,
                                      objQuoteDetail,
                                      "QuoteDetail",
                                      function () { },
                                      function (error) {
                                          alert("Please retry updating the date as there was some problem. \r\l" + error.message);
                                      });
                //wait .5 seconds
                var dt = new Date();
                dt.setTime(dt.getTime() + 500);
                while (new Date().getTime() < dt.getTime());
            }

1 comment:

  1. • I very much enjoyed this article. Nice article thanks for given this information. I hope it useful to many Peopledata since Online Training

    ReplyDelete

Note: Only a member of this blog may post a comment.