locked
Firing Plugin after workflow update RRS feed

  • Question

  • hello,

    How i can triger a plugin after a workflow update a field!? example datefield a litle of orientation.

    Thanks in advance,

    JP

    Thursday, January 20, 2011 4:22 PM

All replies

  • Hello Juan.

    To trigger the plugin when the field is updated you just should register plugin on Update message and include your field to the list of fields which will invoke plugin triggering.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, January 20, 2011 4:43 PM
    Moderator
  • I will check.

    thanks

    Thursday, January 20, 2011 4:50 PM
  • Now the workflow dont work. i use update pre stage.

    Greetings,

    JP

    Thursday, January 20, 2011 8:17 PM
  • Are you sure that your plugin works correctly?
    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, January 20, 2011 8:21 PM
    Moderator
  • Yes, firts update a field and have a check, then validate other stuf and assing there is where crash.

    my code is like this

    if (entity.Properties.Contains("new_pasoactualid"))
      {
       DateTime Fecha = DateTime.Now;
              
      CrmDateTime Fechainicio = new CrmDateTime();
      Fechainicio = (CrmDateTime)entity.Properties["new_fechainicio"];
      Fecha = Convert.ToDateTime(Fechainicio.Value);
      Lookup PasoActual = new Lookup();
      PasoActual = (Lookup)entity.Properties["new_pasoactualid"];
    
      Fecha = Fecha.AddMonths(2);
      Fecha = Fecha.AddDays(-1);
      CrmDateTime FechaFP = new CrmDateTime();
      FechaFP.Value = Fecha.ToString("MM/dd/yyyy HH:mm:ss");
      entity["new_fechalimitepasoactual"] = FechaFP;
    
       }
    
    thanks in advance
    Thursday, January 20, 2011 8:46 PM
  • Hello Juan.

    You should switch on trace , make iisreset and reproduce error. Check the error in log - it will help you to find the source of error.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Thursday, January 20, 2011 9:33 PM
    Moderator
  • Dont work, i retrieve a trace

    at CompositeSoapExtensionExceptionHandler.Handle(Stream to, Stream from, Exception exception)
    at CrmAuthenticationSoapExtensionBase.ProcessMessage(SoapMessage message)
    at SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
    at SoapServerProtocol.WriteException(Exception e, Stream outputStream)
    at WebServiceHandler.WriteException(Exception e)
    at WebServiceHandler.Invoke()
    at WebServiceHandler.CoreProcessRequest()
    at SyncSessionlessHandler.ProcessRequest(HttpContext context)
    at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    at ApplicationStepManager.ResumeSteps(Exception error)
    at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
    at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
    at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
    at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    >CrmSoapExtension detected CrmException:
    System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Microsoft.Crm.CrmException: Entity Name was not specified in FetchXml String.
    at Microsoft.Crm.Query.EntityExpression.InternalFromFetch(String fetchXml, DynamicMetadataCache dynamicCache, Guid organizationId)
    at Microsoft.Crm.Query.EntityExpression.FromFetch(String fetchXml, Guid organizationId)
    at Microsoft.Crm.ObjectModel.QueryService.FetchXmlToEntityExpression(String fetchXml, ExecutionContext context)
    --- End of inner exception stack trace ---
    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object target, Object[] values)
    at Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IPluginExecutionContext context)
    at Microsoft.Crm.Extensibility.PluginStep.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.Execute(String messageName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, PropertyBag fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at Microsoft.Crm.Sdk.RequestBase.Process(Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at Microsoft.Crm.Sdk.RequestBase.Process(CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at Microsoft.Crm.Sdk.CrmServiceInternal.Execute(RequestBase request, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at Microsoft.Crm.Sdk.Crm2007.CrmService.Execute(Request request)
    --- End of inner exception stack trace ---
    
    Thanks in advance.
    • Edited by Juan Solares Friday, January 21, 2011 4:33 PM thank
    Friday, January 21, 2011 4:32 PM
  • was a string character was 200 i set to 1500 now i recieve a sql error

     

    at BusinessProcessObject.ExecuteNonQuery(IDbCommand command, ISqlExecutionContext context)
    at PointerTrigger.Create(Guid id)
    at TriggersExtension.ExecuteTriggers(IBusinessEntity entity, ArrayList triggers, OperationType operationType)
    at BusinessProcessObject.DoCreate(IBusinessEntity entity, ExecutionContext context)
    at TaskService.Microsoft.Crm.Sdk.ICreatable.DoCreate(IBusinessEntity , ExecutionContext )
    at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at LogicalMethodInfo.Invoke(Object target, Object[] values)
    at InternalOperationPlugin.Execute(IPluginExecutionContext context)
    at PluginStep.Execute(PipelineExecutionContext context)
    at Pipeline.Execute(PipelineExecutionContext context)
    at MessageProcessor.Execute(PipelineExecutionContext context)
    at InternalMessageDispatcher.Execute(PipelineExecutionContext context)
    at ExtensiblePlatformMessageDispatcher.Execute(PipelineExecutionContext pluginContext)
    at ExtensiblePlatformMessageDispatcher.Create(BusinessEntity entity, ExecutionContext context)
    at BusinessProcessObject.Create(IBusinessEntity entity, ExecutionContext context)
    at GenericActivityServiceBase.Create(IBusinessEntity entityInterface, ExecutionContext context)
    at TaskService.Create(IBusinessEntity entity, ExecutionContext context)
    at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at LogicalMethodInfo.Invoke(Object target, Object[] values)
    at InternalOperationPlugin.Execute(IPluginExecutionContext context)
    at PluginStep.Execute(PipelineExecutionContext context)
    at Pipeline.Execute(PipelineExecutionContext context)
    at MessageProcessor.Execute(PipelineExecutionContext context)
    at InternalMessageDispatcher.Execute(PipelineExecutionContext context)
    at ExternalMessageDispatcher.Execute(String messageName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, PropertyBag fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at CrmServiceInternal.Create(String namespaceName, BusinessEntityBase entity, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId)
    at CrmService.Create(BusinessEntity entity)
    at RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
    at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
    at RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
    at LogicalMethodInfo.Invoke(Object target, Object[] values)
    at WebServiceHandler.Invoke()
    at WebServiceHandler.CoreProcessRequest()
    at SyncSessionlessHandler.ProcessRequest(HttpContext context)
    at CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    at ApplicationStepManager.ResumeSteps(Exception error)
    at HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
    at HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
    at HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
    at ISAPIRuntime.ProcessRequest(IntPtr ecb, Int32 iWRType)
    >Exception when executing non-query: insert into ActivityPointerBase(ActivityId, Description, OwningBusinessUnit, RegardingObjectIdDsc, RegardingObjectTypeCode, StateCode, StatusCode, Subject, ScheduledEnd, RegardingObjectId, IsWorkflowCreated, CreatedOn, IsBilled, DeletionStateCode, OwningUser, ModifiedBy, CreatedBy, PriorityCode, ModifiedOn, RegardingObjectIdName, ActivityTypeCode) values ('63d9649b-5a0d-4148-b1f6-96d23f87057e', 'Responsable: Gerente - Grupo Sega', '4e329feb-2a18-e011-823e-000c298087da', 0, 10006, 0, 2, 'T-34: Plan de Cuenta y Revisión de Plan - Actividad: Creación y validar los servicios incluidos en el Plan de Cuenta General que se presentará en la segunda visita. Asimismo, será el encargado de brindar información sobre cualquier servicio que sea incluido en el Plan Anual de Actividades Detallado.', NULL, '89b91e15-7f25-e011-8c59-000c298087da', 1, '01/21/2011 16:55:03', 0, 0, '69439feb-2a18-e011-823e-000c298087da', '69439feb-2a18-e011-823e-000c298087da', '69439feb-2a18-e011-823e-000c298087da', 1, '01/21/2011 16:55:03', 'Test', 4212) Exception: System.Data.SqlClient.SqlException: String or binary data would be truncated.
    The statement has been terminated.
    at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
    at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
    at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
    at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
    at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
    at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
    at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
    at Microsoft.Crm.CrmDbConnection.InternalExecuteNonQuery(IDbCommand command)
    at Microsoft.Crm.CrmDbConnection.ExecuteNonQuery(IDbCommand command, Boolean impersonate)
    at Microsoft.Crm.BusinessEntities.BusinessProcessObject.ExecuteNonQuery(IDbCommand command, ISqlExecutionContext context)

    Thanks in advance

    JP

    Friday, January 21, 2011 5:05 PM