Microsoft Dynamics CRM工作流程教程不起作用

时间:2018-06-26 15:14:18

标签: c# sdk dynamics-crm microsoft-dynamics

我正在尝试遵循本教程: https://msdn.microsoft.com/en-us/library/gg509012.aspx

但是,当我上线时:

protected override void Execute(CodeActivityContext executionContext)
{
    IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

    //Create an Organization Service
    IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);

    //Retrieve the contact id
    Guid contactId = this.Contact.Get(executionContext).Id;
}

它在C#中给出错误。

  

C#'Program'不包含'Contact'的定义,找不到找不到使用指令或程序集引用的扩展方法'Contact'接受类型为'Program'的第一个参数?

什么是this.Contact

1 个答案:

答案 0 :(得分:3)

联系人是自定义活动工作流程的输入参数

//Define the properties
[RequiredArgument]
[Input("Update Next Birthdate for")]
[ReferenceTarget("contact")]

public InArgument<EntityReference> Contact { get; set; }

protected override void Execute(CodeActivityContext executionContext)
{
    IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

    //Create an Organization Service
    IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.InitiatingUserId);

    //Retrieve the contact id
    Guid contactId = this.Contact.Get(executionContext).Id;
}

从工作流或操作中调用自定义时,必须发送所需的输入参数,例如Contact。