locked
CRM 2011 Bulk Delete Transaction RRS feed

  • Question

  • Hi,

    I am using CRM 2011 Bulk request to delete data from multiple entities through c# code.My doubt is if i execute multiple Query expression as one Bilk delete request job will it suppor Database Transaction?

    For example i want delete Case and its activities if there any error in any one of entity then i want rollback the action.

    will it delete the order that we supplied the Query expressions?

    var bulkDeleteRequest = new BulkDeleteRequest
                    {
                        JobName = "Sample Bulk Delete",
                        QuerySet = new[] { activityExp,caseExp,ContactExp},
                        StartDateTime = DateTime.Now,
                        CCRecipients = new Guid[] {}
                    };

    Here i want delete activityExp first ,CaseExp as second and ContactExp as Last,so if any error in any experssion then i want rollback all expressions.

    so is bulk operation will fulfill my needs?

    Thanks





    Thursday, February 27, 2014 5:30 PM

Answers

  • BulkDelete is not executed as a transaction. CRM will delete the records as separate data operations.

    The only way to control transactions in CRM is to execute data operations within a plugin, which can run in the context of the parent operation. However, I don't think you'd be able to make this work in this case, especially as, if you have a lot of data, then the plugin is likely to timeout. Note also, that if you tried this, you'd have to submit individual Delete requests, as BulkDelete is run by the AsyncService, so it will be in a separate transaction from the plugin.

    One of the reasons why it is not easy to control transactions is that any long transaction will hold database locks, which can severely impact the performance of CRM


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Proposed as answer by Linn Zaw Win Friday, February 28, 2014 2:36 AM
    • Marked as answer by alagesanit2009 Friday, February 28, 2014 9:49 AM
    Thursday, February 27, 2014 10:24 PM
    Moderator

All replies

  • BulkDelete is not executed as a transaction. CRM will delete the records as separate data operations.

    The only way to control transactions in CRM is to execute data operations within a plugin, which can run in the context of the parent operation. However, I don't think you'd be able to make this work in this case, especially as, if you have a lot of data, then the plugin is likely to timeout. Note also, that if you tried this, you'd have to submit individual Delete requests, as BulkDelete is run by the AsyncService, so it will be in a separate transaction from the plugin.

    One of the reasons why it is not easy to control transactions is that any long transaction will hold database locks, which can severely impact the performance of CRM


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    • Proposed as answer by Linn Zaw Win Friday, February 28, 2014 2:36 AM
    • Marked as answer by alagesanit2009 Friday, February 28, 2014 9:49 AM
    Thursday, February 27, 2014 10:24 PM
    Moderator
  • Hi,

    Thanks for your reply.

    If i run multipley query expressions in a bulk job will it delete by order that i submitted?

    Thanks

    Friday, February 28, 2014 9:52 AM