locked
CRM 2011: Updating the reocrd in plugin after invalid plugin execution exception RRS feed

  • Question

  • HI All,

    I am updating the record which triggering a plugin. on a webexception I am trying to update the same record in catch block, but not successful. If I use ExecuteMultipleRequest with continueonError = true, then program stucks and crash with timeout exception.

    If I user OrgService.Update then it rolls it back.

    Please suggest.

    THanks


    Hassan

    Wednesday, January 28, 2015 7:24 AM

All replies

  • share your code, so someone can look and propose suggestions

    My blog: www.crmanswers.net - Rockstar 365 Profile

    Wednesday, January 28, 2015 7:42 AM
  • Structure is something like this:

    public voidExecute(IServiceProviderserviceProvider)
    {

            

       try{  }

        catch(WebException ex){

             

                 //upon failure of re-enrolment set the application back to normal settings
                    Entity app = new Entity("contact");

                    app["middlename"] = "test";

                    app.Id = contact.Id;

                    UpdateRequest updateRequest = new UpdateRequest();

                    updateRequest.Target = app;

                    ExecuteMultipleRequest mulReq = new ExecuteMultipleRequest()

                              

                    {

                       Requests = new OrganizationRequestCollection(),

                       Settings = new ExecuteMultipleSettings()

                          {

                              ContinueOnError = true,

                               ReturnResponses =
    false

                           }

                      };

                      mulReq.Requests.Add(updateRequest);

                               

                      var reqponse = service.Execute(mulReq);

                    

                           

                     if(webEx.Response != null)

                     {

                               

                       if(webEx.Response.ContentLength > 0)

                        {

                                   

                             WebApiResult<RegisterForPreEnrolmentRequestMessage> resultEx = ParseResponse<WebApiResult<RegisterForPreEnrolmentRequestMessage>>(webEx.Response.GetResponseStream());

                             HandleWebApiError(resultEx.Error);

                         }

                   }

         }

    }

    In exception block if I use different record then it updates but if I use the same record to update in executemultiplerequest then it just freezes and comes back with timeout exception.

    please suggest!

    Thanks


    Hassan


    • Edited by Hassanz Wednesday, January 28, 2015 11:26 PM
    Wednesday, January 28, 2015 11:13 PM