簡體   English   中英

此工作流無法運行,因為父工作流提供的參數與鏈接子工作流中的指定參數不匹配

[英]This workflow cannot run because arguments provided by parent workflow does not match with the specified parameters in linked child workflow

我正在嘗試從我的 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# 代碼或工作流代碼有什么問題。

我將假設您沒有在此處使用XAML 工作流

我認為您將工作流與自定義工作流活動 (CWA) 混淆了,即使如此,我認為您的設計可能是錯誤的。

工作流是使用工作流設計器通過 CRM 用戶界面配置的過程。 工作流包含許多步驟。 工作流可以由系統事件和ExecuteWorkflowRequest調用觸發。

CWA 是一段代碼,您可以將其作為一個步驟打包並放置在流程中。 CWA 只能通過進程觸發。 您不能使用ExecuteWorkflowRequest調用來直接訪問 CWA。 您需要設計一個流程,然后將您的 CWA 作為一個步驟添加到其中,通過工作流設計器傳遞輸入。

您的實現表明您想要創建一個端點,您可以向其傳遞參數,然后運行一些自定義代碼。 在這種情況下,工作流在任何情況下都不起作用 - 它無法接收輸入(我懷疑這是導致錯誤的原因)。 您應該考慮允許定義輸入參數的操作(另一種類型的過程)。 該操作也是使用工作流設計器實現的,因此您可以調用 CWA,然后傳遞來自該操作的參數。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM