Custom CRM workflow that creates a task
I created a custom workflow activity in CRM that creates a task. The workflow is associated with an opportunity. When I create my task, I would like to ask "aboutobjectid" the management of the appropriate opportunity.
ICrmService crmService = context.CreateCrmService();
task entity = new task();
entity.subject = taskSubject;
entity.regardingobjectid.Value = ??????
crmService.Create(entity);
Is it possible? I thought it would be easy.
+2
source to share
1 answer
Assuming the first few lines of your activity looks like this:
IContextService contextService = (IContextService)executionContext.GetService(typeof(IContextService));
IWorkflowContext context = contextService.Context;
Then you can do this:
entity.regardingobjectid = new Lookup("opportunity", context.PrimaryEntityId);
+2
source to share