Quantcast
Viewing all articles
Browse latest Browse all 79901

SDK.REST.updateRecord and SqlException: Transaction was deadlocked on lock resources

I am reading quoteproduct id's using SDK.Rest.retrieveMultipleRecords from the quote form when a particular on change event happens. The intent is to update the quoteproduct records at that time if the user response appropriately to a javascript confirm dialog. What is happening is that when i call SDK.Rest.updateRecord, I frequently (not always) get a deadlock condition. See full error message below.  I have tried a few variations but the basic code that works most of the time is below. Any ideas?

function BreakoutDate_OnChange() {
    var breakoutDate = GetDate("xxx_breakoutduedate", 1);

    var quoteId = GetThisGuid();
    quoteId = quoteId.replace("{", "").replace("}", "");

    var options = "$select=QuoteDetailId&$filter=QuoteId/Id eq guid'" + quoteId + "'";
    var retrievedData;
    SDK.REST.retrieveMultipleRecords(   "QuoteDetail",
                                        options,
                                        RetrievedQuoteProductRecs,       /* success function */
                                        function (error) {
                                            alert(error.message);
                                        },
                                        function () { /* do nothing in completed function */ });
}
function RetrievedQuoteProductRecs(retrievedData) {
    var breakoutDate = GetDate("xxx_breakoutduedate", 1);

    for (var i = 0; i < retrievedData.length; i++) {
        var quoteProduct = {};
        quoteProduct.xxx_breakoutduedate = breakoutDate;

        SDK.REST.updateRecord(  retrievedData[i].QuoteDetailId,
                                quoteProduct,
                                "QuoteDetail",
                                function () { /* Just be happy it didn't throw an error! */ },
                                function (error) {
                                    alert(error.message);
                                });
    }
} 





Viewing all articles
Browse latest Browse all 79901

Trending Articles



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