【问题标题】:Dynamics CRM - Custom Workflow - reading input parameter stops plugin from running?Dynamics CRM - 自定义工作流程 - 读取输入参数会阻止插件运行?
【发布时间】:2016-10-24 21:27:30
【问题描述】:

我有一个自定义工作流活动,它接受一个名为“InputTest”的输入参数。这只是一个字符串。

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

在我的自定义工作流活动中,我想阅读它,所以我执行以下操作:

string targetEntityValue = TargetEntity.Get(executionContext);

添加该行后,我的工作流活动将不再执行。当我运行它时,状态将显示“Succeeded”,但工作流中的任何内容都不会运行,甚至工作流开始时的跟踪也不会显示工作流已进入。诊断日志中没有任何内容。当我运行 SQL Profiler 时,只有几条语句添加到 AsyncBase 表中,表明工作流已经运行并立即完成。

如果我删除上述行,则工作流程运行正常。我想知道我在这里做错了什么?为什么读取输入参数会导致 CRM 在工作流程中不执行任何操作?

这几乎就像代码没有进入它的主要方法一样。

[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);
}

【问题讨论】:

  • 您使用的是什么 CRM 版本,以及什么 SDK 版本?
  • Dynamics CRM 2016 本地部署。

标签: c# dynamics-crm


【解决方案1】:

好吧,这很奇怪。最后我绝望了,所以我用新的程序集名称创建了一个新项目,将代码重新添加并部署,现在它工作正常。

所以..我认为要么:

  • 这是我的第一个自定义工作流插件,所以也许我以某种方式错误地设置了原始项目,并且由于某种原因它没有进入其主要方法。

  • 在 CRM 服务器上部署原始插件存在某种问题。

不知道为什么 CRM 会运行插件并返回“成功”状态而不运行 main 方法。

【讨论】:

    【解决方案2】:

    如果您想读取自定义工作流活动参数,正确的语法是:

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

    【讨论】:

    • 不走运 - 添加了 但工作流仍然没有运行 :(
    • 如果我删除插件执行的那一行... :/
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多