我在CRM中创建了一个创建任务的自定义工作流活动。工作流程附加到机会。当我创建我的任务时,我想设置“ aboutobjectid”指导相关的机会。

        ICrmService crmService = context.CreateCrmService();
        task entity = new task();
        entity.subject = taskSubject;
        entity.regardingobjectid.Value = ??????
        crmService.Create(entity);

这可能吗?我觉得这很简单。

有帮助吗?

解决方案

假设您活动的前几行看起来像这样:

IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));   
IWorkflowContext context = contextService.Context;

然后你应该能够做到这一点:

entity.regardingobjectid = new Lookup("opportunity", context.PrimaryEntityId);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top