【问题标题】:This workflow cannot run because arguments provided by parent workflow does not match with the specified parameters in linked child workflow此工作流无法运行,因为父工作流提供的参数与链接的子工作流中的指定参数不匹配
【发布时间】:2018-02-16 09:19:26
【问题描述】:

我正在尝试从我的 C# 代码调用 Dynamics CRM 工作流。我的工作流程需要来自我的 C# 代码的参数。我正在使用流动代码:

var workflowInfo = result.Entities.FirstOrDefault();
if (workflowInfo != null)
{
InputArgumentCollection inputParameters = new InputArgumentCollection();

EntityReference reference = new EntityReference();
reference.Id = paymentRunID;
reference.Name = "paymentrunid";
reference.LogicalName = "paymentrun";                    
inputParameters.Add("InputPaymentRunID", reference);

inputParameters.Add("InputPaymentDueDate", paymentRunPayDate);

OptionSetValue opt = new OptionSetValue();
opt.Value = region;
inputParameters.Add("InputRegion", opt);

var request = new ExecuteWorkflowRequest();
request.WorkflowId = workflowInfo.GetAttributeValue<Guid>("workflowid"); //ID of the workflow to execute
request.EntityId = paymentRunID; //ID of the record on which the workflow executes                    
request.InputArguments = inputParameters;

ServerConnection.CrmService.Execute(request);
return true;
}

我的 CRM 工作流程端的代码是:

[RequiredArgument]
[Input("EntityReference input")]
[ReferenceTarget("paymentrun")]
public InArgument<EntityReference> InputPaymentRunID { get; set; }

[Input("DateTime input")]
public InArgument<DateTime> InputPaymentDueDate { get; set; }

[Input("OptionSetValue input")]
[Default("1")]
[AttributeTarget("paymentrun", "lregion")]
public InArgument<OptionSetValue> InputRegion { get; set; } 

当我运行我的 C# 代码时,它已成功执行并返回 true,但在我的 Dynamics CRM 工作流程端,我收到以下错误:

This workflow cannot run because arguments provided by parent workflow does not match with the specified parameters in linked child workflow. Check the child workflow reference in parent workflow and try running this workflow again.

Unhandled Exception: Microsoft.Crm.CrmException: This workflow cannot run because arguments provided by parent workflow does not match with the specified parameters in linked child workflow. Check the child workflow reference in parent workflow and try running this workflow again.
at Microsoft.Crm.Workflow.Services.InputArgumentValidator.VerifyAndFilterInputParametersSupplied(Dictionary`2 inputArguments, Dictionary`2 childParameters)
at Microsoft.Crm.Workflow.ActivityHostBase.FetchInputArguments(ICommonWorkflowContext context)
at Microsoft.Crm.Workflow.ActivityHost.StartWorkflowExecution(Activity workflow, ICommonWorkflowContext context)
at Microsoft.Crm.Workflow.ActivityHostBase.StartWorkflow(ICommonWorkflowContext context, Activity preLoadedActivity)

C# 代码或工作流代码有什么问题。

【问题讨论】:

  • 您提供的代码中的dynamics 部分不是 Workflow 它是custom activity。要使其运行,您应该将其用作workflow 的一部分,它将在您的自定义步骤中提供参数(基于自定义活动)。请检查您的Workflow 内容(不是Activity),如果仍然没有给出答案,请在问题中分享内容
  • 必须查看调用此自定义 WF 活动的 UI 工作流屏幕截图。似乎有些孩子WF被称为,对吧?从 CRM UI 触发时,此 UI 工作流是否成功运行? (可按需提供)

标签: c# dynamics-crm


【解决方案1】:

我假设你在这里没有使用XAML workflow

我认为您将工作流与自定义工作流活动 (CWA) 混淆了,即使这样我也认为您的设计可能是错误的。

工作流程是使用工作流程设计器通过 CRM 用户界面配置的流程。工作流包含许多步骤。工作流程可以由系统事件和ExecuteWorkflowRequest 调用触发。

CWA 是一段代码,您可以打包并作为一个步骤放置在流程中。 CWA 只能通过进程触发。您不能使用 ExecuteWorkflowRequest 调用直接访问 CWA。您需要设计一个流程,然后将您的 CWA 作为一个步骤添加到其中,通过工作流设计器传递输入。

您的实现建议您要创建一个端点,您可以将参数传递给然后运行一些自定义代码。在这种情况下,工作流在任何情况下都不起作用 - 它无法接收输入(我怀疑这是您的错误的原因)。您应该考虑允许定义输入参数的操作(另一个type 进程)。该操作也是使用工作流设计器实现的,因此您可以调用您的 CWA,然后传递来自操作的参数。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多