locked
Plugin Update downloading current entity Reports cause time our error RRS feed

  • Question

  • Hi ,

    I am troubleshooting with this issue from a week. i tried to post the issue through other sites i dint get any response.. please respond to my issue,

    My task is to download the report from workorder entity form and save to local file.

    initially i created plugin on workorder entty for Update step. I have Report which  need to download and save the report by Form ID. In my report Prompt parameter is Entity ID. when am rendering the report though current Entity ID it gives time out exception.  if i hard code different form id through parameter value its rendering report bytes when i refer dynamical form id its giving channel time out exception.

    I tried to trace report parameters value..its referring to right values but its throwing timeout exception..any one know the reason to time out  for current form id.. i tried to set the time out for 5 minuts..after 5 minutes its thworing the error by saying increase sendtimeout value.. :(

    My error,

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.The HTTP request to 'http://xxxx/ReportServer/ReportExecution2005.asmx' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.
    Server stack trace: 
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
        <KeyValuePairOfstringanyType>
          <d2p1:key>OperationStatus</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.The HTTP request to 'http://xxxx/ReportServer/ReportExecution2005.asmx' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.
    Server stack trace: 
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)


    Since its giving timeout exception for currrent form id i started working with different approach.

    I created Custom Entity with wordorderid field and  created second plugin on CustomEntity for Create step post synchronus step.   it download the report by reading workorder id from custom entity workorderid field. 

    My first plugin created for Work order entity Update for Post synchronous step . it creates new record by setting workorderid field under custom enitity .  when second plugin fires it will be reading workorderid  from ewly created row from 1st plugin.

    My first plugin fires on workorder update it throws below error.'Need to start a transaction before commit'

     when i disable second plugin first plugin works fine by creating new record through custom entity.

    when i enable second plugin[On create of custom entity] am getting  below error. i tried to set up second plugin step asynchronously .. but second plugin not firing asynchronously.

    'Need to start a transaction before commit'.

    why??? please suggest me..

    Error,

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Need to start a transaction before commitDetail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220911</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
        <KeyValuePairOfstringanyType>
          <d2p1:key>CallStack</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, String messageName, String requestName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, ParameterCollection fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId, Guid transactionContextId, Int32 invocationSource, Nullable`1 requestId, Version endpointVersion)
       at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)
       at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)</d2p1:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>Need to start a transaction before commit</Message>
      <Timestamp>2013-07-23T21:12:33.0259135Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText i:nil="true" />
    </OrganizationServiceFault>

    My code for 1st plug in,

     public void Execute(IServiceProvider serviceProvider)
            {
                IPluginExecutionContext context = (IPluginExecutionContext)
                serviceProvider.GetService(typeof(IPluginExecutionContext));
                Entity entity;
                ITracingService TracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
                // Check if the input parameters property bag contains a target
                // of the create operation and that target is of type Entity.
                if (context.InputParameters.Contains("Target") &&
                context.InputParameters["Target"] is Entity)
                {
                    // Obtain the target business entity from the input parameters.
                    entity = (Entity)context.InputParameters["Target"];
                    // Verify that the entity represents a contact.
                    if (entity.LogicalName != "new_workorder") { return; }
                }
                else
                {
                    return;
                }
                try
                {
                    TracingService.Trace("loading service factory");
                    IOrganizationServiceFactory serviceFactory =
                        (IOrganizationServiceFactory)serviceProvider.GetService(
                    typeof(IOrganizationServiceFactory));
                    IOrganizationService service =
                    serviceFactory.CreateOrganizationService(context.UserId);
                    var id = entity.Id;
                    var crmContext = new XrmServiceContext(service);               
                    var contact1 = crmContext.New_WorkOrderSet.Where(w => w.New_WorkOrderId == id).First();
                    new_esignature esign = new new_esignature();//custom entity
                  
                    if (!string.IsNullOrEmpty(contact1.new_inpersonsigninglinks) && !string.IsNullOrEmpty(contact1.new_EmailSigningLinks))
                    {
                        TracingService.Trace("Creating new record  new_esignature");
                        esign.new_WorkOrderID = id.ToString();
                        crmContext.Create(esign);
                    }
                }

    second plugin,

      public void Execute(IServiceProvider serviceProvider)
            {
                IPluginExecutionContext context = (IPluginExecutionContext)
                serviceProvider.GetService(typeof(IPluginExecutionContext));
                
                Entity entity;
                
                ITracingService TracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
                // Check if the input parameters property bag contains a target
                // of the create operation and that target is of type Entity.
                if (context.InputParameters.Contains("Target") &&
                context.InputParameters["Target"] is Entity)
                {
                    // Obtain the target business entity from the input parameters.
                    entity = (Entity)context.InputParameters["Target"];
                    // Verify that the entity represents a work order.
                   // if (entity.LogicalName != "new_workorder") { return; }
                    //new
                    if (entity.LogicalName != "new_esignature") { return; }
                }
                else
                {
                    return;
                }
                try
                {
                    TracingService.Trace("loading service factory");
                    IOrganizationServiceFactory serviceFactory =
                        (IOrganizationServiceFactory)serviceProvider.GetService(
                    typeof(IOrganizationServiceFactory));
                    TracingService.Trace("generating organization service from factory");
                    IOrganizationService service =
                    serviceFactory.CreateOrganizationService(context.UserId);
     var crmContext = new XrmServiceContext(service);        
                    var contact1 = crmContext.new_esignatureSet.Where(w => w.new_esignatureId == esignid).First();
                    string workorderid = contact1.new_WorkOrderID;
    CreateReportPDF(sFilepath, workorderid.ToString(), id, ref TracingService);

    Can anyone suggest me best approach??



    Tuesday, July 23, 2013 10:05 PM

All replies

  • Hey,

    if i disable my 2nd plugin 1st plugin working fine.

    my 1st plugin can update curent workorder entity and creating new record through custom entity.  when i enable second plugin[On create of custom entity] am getting  below error.

    Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Need to start a transaction before commitDetail: 
    <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts">
      <ErrorCode>-2147220911</ErrorCode>
      <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic">
        <KeyValuePairOfstringanyType>
          <d2p1:key>CallStack</d2p1:key>
          <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
       at Microsoft.Crm.Extensibility.ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, String messageName, String requestName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, ParameterCollection fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId, Guid transactionContextId, Int32 invocationSource, Nullable`1 requestId, Version endpointVersion)
       at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)
       at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)</d2p1:value>
        </KeyValuePairOfstringanyType>
      </ErrorDetails>
      <Message>Need to start a transaction before commit</Message>
      <Timestamp>2013-07-24T15:46:57.7156295Z</Timestamp>
      <InnerFault i:nil="true" />
      <TraceText i:nil="true" />
    </OrganizationServiceFault>

    why its not calling through second plugin??
    Wednesday, July 24, 2013 3:50 PM