3
votes

I have a custom workflow activity which accepts an input parameter called "InputTest". This is just a string.

[Input("InputTest")]
[RequiredArgument]
public InArgument<string> TargetEntity { get; set; }

In my custom workflow activity I want to read it, so I do the following:

string targetEntityValue = TargetEntity.Get(executionContext);

As soon as I add that line my workflow activity will no longer execute. When I run it the status will show "Succeeded" but nothing in the workflow will have run, not even the trace at the beginning of the workflow to say the workflow has been entered. There is nothing in the Diag Logs. When I run the SQL Profiler there are only a few statements added to the AsyncBase table showing that the workflow has run and instantly finished.

If I remove the above line the workflow runs ok. I am wondering what I am doing wrong here? Why would reading an input parameter cause CRM not to do anything in the workflow?

It is almost like somehow the code isnt entering its main method.

[Input("Entity")]
[RequiredArgument]
public InArgument<string> TargetEntity { get; set; }

protected override void Execute(CodeActivityContext executionContext)
{
    // Create the tracing service
    ITracingService tracingService = executionContext.GetExtension<ITracingService>();

    if (tracingService == null)
    {
        throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
    }

    tracingService.Trace("Entered TestWorkflow.Execute(), Activity Instance Id: {0}, Workflow Instance Id: {1}",
    executionContext.ActivityInstanceId,
    executionContext.WorkflowInstanceId);

    string targetEntityValue = TargetEntity.Get<string>(executionContext);
}
2
What CRM version are you on, and what SDK version ?Alex
Dynamics CRM 2016 on-prem.Dean

2 Answers

1
votes

Ok well this was very strange. In the end I got desperate so I created a new project with a new assembly name, added the code back in and deployed and now it is working fine.

So.. I think either:

  • This is my first custom workflow plugin so perhaps I set up the original project wrong somehow and for some reason it was not entering its main method.

  • There is some kind of issue with the deployment of the original plugin on the CRM server.

Quite why CRM would run a plugin and return status of "Success" without running the main method I am not sure.

0
votes

if you want to read a Custom Workflow Activity parameter, the right syntax is:

string targetEntityValue = TargetEntity.Get<string>(executionContext);