C# 此工作流无法运行,因为父工作流提供的参数与链接子工作流中的指定参数不匹配

C# 此工作流无法运行,因为父工作流提供的参数与链接子工作流中的指定参数不匹配,c#,dynamics-crm,C#,Dynamics Crm,我正在尝试从我的C#代码调用Dynamics CRM工作流。我的工作流需要来自我的C#代码的参数。我正在使用流动代码: var workflowInfo = result.Entities.FirstOrDefault(); if (workflowInfo != null) { InputArgumentCollection inputParameters = new InputArgumentCollection(); EntityReference reference = new Ent

我正在尝试从我的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;
}
C代码或工作流代码有什么问题。

我假设您没有在此处使用

我认为您将工作流与自定义工作流活动(CWA)混淆了,甚至我认为您的设计可能是错误的

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

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


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

您提供的
动态
部分代码它不是
工作流
它是
自定义活动
。要使其运行,应将其作为
工作流的一部分使用,该工作流将在自定义步骤中提供参数(基于自定义活动)。请检查您的
工作流
内容(不是
活动
),如果仍然没有给出答案,请共享问题中的内容。您必须查看调用此自定义WF活动的UI工作流屏幕截图。好像有个叫WF的孩子,对吧?当从CRM UI触发时,此UI工作流是否成功运行?(可根据需要提供)
[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; } 
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)