gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 15:01:06 25 4
gpt4 key购买 nike

我正在尝试从我的 C# 代码调用 Dynamics CRM 工作流。我的工作流程需要来 self 的 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# 代码或工作流代码有什么问题。

最佳答案

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

我认为您将工作流与自定义工作流事件 (CWA) 混淆了,即便如此我认为您的设计也可能是错误的。

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

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

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

关于c# - 此工作流无法运行,因为父工作流提供的参数与链接的子工作流中的指定参数不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46099678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com