Dear Reader,
i have a Problem with executing a workflow manually: WorkflowCommon.TARGET is not present in the dictionary
InputParameters.
If i use the workflow triggered by create, fields changed, etc. it works great.
The Code:
public override void Process(WorkflowContext context)
{
Entity mainEntity = (Entity)context.Context.InputParameters[WorkflowCommon.TARGET];
String entityRelationshipName = Relationship.Get<String>(context.ExecutionContext);
Entity subEntity;
String subEntityFieldName;
RetrieveRelationship(context.Service, entityRelationshipName, mainEntity, out subEntity, out subEntityFieldName);
EntityCollection subEntities = RetrieveSubEntities(context.Service, mainEntity, subEntity, subEntityFieldName);
Count.Set(context.ExecutionContext, subEntities.Entities.Count());
}
AND:
public WorkflowContext(CodeActivityContext executionContext, String activityName)
{
ExecutionContext = executionContext;
ActivityName = activityName;
LogFactory = new ChannelFactory<IAssLogConnection>(new BasicHttpBinding(), new EndpointAddress(WorkflowCommon.LOG_ENDPOINT_ADDRESS));
if (LogFactory == null) throw new InvalidPluginExecutionException(ErrorMessage.FAILED_TO_RETRIEVE_LOG_CONNECTION_SERVICE);
LogConnectionService = LogFactory.CreateChannel();
if (LogConnectionService == null) throw new InvalidPluginExecutionException(ErrorMessage.FAILED_TO_RETRIEVE_LOG_CONNECTION_SERVICE);
if (ExecutionContext == null) throw new InvalidPluginExecutionException(ErrorMessage.FAILED_TO_RETRIEVE_EXECUTION_CONTEXT);
TracingService = ExecutionContext.GetExtension<ITracingService>();
if (TracingService == null) throw new InvalidPluginExecutionException(ErrorMessage.FAILED_TO_RETRIEVE_TRACING_SERVICE);
TracingService.Trace(ErrorMessage.ENTERED_EXECUTE_FORMAT_3,
ActivityName,
ExecutionContext.ActivityInstanceId,
ExecutionContext.WorkflowInstanceId);
Context = ExecutionContext.GetExtension<IWorkflowContext>();
if (Context == null) throw new InvalidPluginExecutionException(ErrorMessage.FAILED_TO_RETRIEVE_WORKFLOW_CONTEXT);
TracingService.Trace(ErrorMessage.INITIATING_USER_FORMAT_3,
ActivityName,
Context.CorrelationId,
Context.InitiatingUserId);
ServiceFactory = ExecutionContext.GetExtension<IOrganizationServiceFactory>();
Service = ServiceFactory.CreateOrganizationService(Context.UserId);
}
Does anyone know, why?