设置自定义活动的OwnerId

Abh*_*tel 2 dynamics-crm-2011

我创建了一个我在工作流程中使用的自定义CRM活动.我将此活动用作自定义工作流活动的InArgument.在Execute()方法中,我试图将自定义CRM活动实例的OwnerId设置为系统用户,并在我使用CrmSvcUtil生成的上下文对象上调用UpdateObject(实体).

[Input("Some name")]
[ReferenceEntity("mycustomactivity")]
[Required]
public InArgument<EntityReference> MyCustomActivity{get;set;}


void Execute(CodeActivityContext context)
{
IOrganizationService svc = context.GetExtension<IOrganizationService>();
var customActivityReference = MyCustomActivity.GetValue(MyCustomActivity);

//MyServiceContext is an OrganizationServiceContext generated using CrmSvcUtil
MyServiceContext servicecontext = new MyServiceContext(svc); 

//GetCutomActivityInstance uses the Id to get an instance of the custom activity) 
MyCustomCRMActivity activityInstance = GetCutomActivityInstance (servicecontext,customActivityReference.Id);

activityInstance.OwnerId = new EntityReference("systemuser",<SomeGUID>);
context.UpdateObject(activityInstance);
context.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)

以上操作不起作用,活动所有者默认为我的crm用户帐户,并且未更新以反映我在activityInstance.OwnerId中设置的所有者

任何帮助将非常感激.

cce*_*lar 6

无法通过更新更改所有者.你必须使用AssignRequest(或内置的Assign-step,见截图)

请参阅此答案/sf/answers/542234381/

在此输入图像描述