locked
Plugin Error "Exceded" while updating entity records. RRS feed

  • Question

  • Hi all,

    I am facing the below issue kindly help..

    In order product entity i am having two look up fields named  existing product which is look up to product entity and order product pointer field which is look up to custom entity named order product pointer. So on the updation of order product record utility created the new record in custom entity named order product pointer and set that record as a look up value in order product pointer field which is on order product form.

    So that utility running fine for 50 records if i set more than 50 records like 51, 52 etc... in plugin that it throws the message "exceeded".

    Below is snap shot of code

    for (int i = 0; i < CustomOrderProductRecords_count; i++) {
    Entity OrderProduct = new Entity("salesorderdetail");
    Entity ent = CustomOrderProductRecords[i];
    Guid OrderId = ((EntityReference)ent.Attributes["salesorderid"]).Id;
    string OrderName = ((EntityReference)ent.Attributes["salesorderid"]).Name;
    // int OrderState = ((OptionSetValue)ent.Attributes["salesorderstatecode"]).Value;
    // throw new InvalidPluginExecutionException("Id: " + OrderId + " OrderName: " + OrderName + " , State: " + OrderState.ToString());
    //&& !OrderId.ToString().ToLower().Contains("eb98b3b3-4253-e111-b398-1cc1dee8ea01")

    if (i < 50 )
    {
    // If Existing Product is updated
    if (ent.Attributes.Contains("productid") && (EntityReference)ent.Attributes["productid"] != null)
    {
    Guid ProductId = ((EntityReference)ent.Attributes["productid"]).Id;
    string ProductName = RetrieveProduct(ref ent, ref context, ref serviceProvider, ref ProductId);
    //throw new InvalidPluginExecutionException("ProductID:" + ProductName);
    CustomOrderProductId = RetrieveCreatedCustomOrderProduct(ref ent, ref context, ref serviceProvider, ref ProductName);
    //Set CustomOrderProduct in OrderProduct.
    // entity.Attributes["new_product"] = new EntityReference("new_orderproductpointer", CustomOrderProductId);
    }
    else if (ent.Attributes.Contains("productdescription") && (string)ent.Attributes["productdescription"] != string.Empty)
    {
    //throw new InvalidPluginExecutionException("productdescription is present ");
    // If Write-in Product is updated
    string ProductName = (string)ent.Attributes["productdescription"];
    CustomOrderProductId = RetrieveCreatedCustomOrderProduct(ref ent, ref context, ref serviceProvider, ref ProductName);
    //Set CustomOrderProduct in OrderProduct.
    //entity.Attributes["new_product"] = new EntityReference("new_orderproductpointer", CustomOrderProductId);
    }

    // Set Field Values -------------------------------------
    OrderProduct.Attributes["new_product"] = new EntityReference("new_orderproductpointer", CustomOrderProductId);
    OrderProduct.Attributes["salesorderdetailid"] = ent.Attributes["salesorderdetailid"]; 
    // Update record
    // throw new InvalidPluginExecutionException("flag is being true: pre ");
    service.Update(OrderProduct);
    }
    }

    I am using crm 2013 online.

    Need help urgently as i need to update more than 50000 records.


    Deepak Jangra

    Wednesday, March 19, 2014 1:41 PM

All replies

  • Is your plugin registered to fire synchronously?

    Plugin will most likely timeout if you have set it synchronously.

    Try register it as an asynchronous event and see what happens.

    Davey

    Wednesday, March 19, 2014 4:27 PM
  • Hi,

    I suspect that your issue is a plugin timeout. Updating 50000 records in a plugin is not really a good idea because there are a variety of timeouts that you will hit - not least the browser timeout where the user is left waiting and wondering what is going on! A better option would be to make the process asynchronous and create a custom workflow activity to do the updates.

    msdn.microsoft.com/.../gg328515.aspx

    Hope this helps,

    Scott


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

    Wednesday, March 19, 2014 9:16 PM
    Answerer