设置自定义活动的OwnerId [英] Setting OwnerId of a custom activity

查看:175
本文介绍了设置自定义活动的OwnerId的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have created a custom CRM activity that I'm using in a workflow. I'm using this activity as an InArgument to a custom workflow activity. In the Execute() method I'm trying to set the OwnerId of the custom CRM activity instance to a system user and calling UpdateObject(entity) on the context object that I have generated using CrmSvcUtil.

[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();
}

以上操作无效,活动所有者默认使用我的crm用户帐户并且不会进行更新以反映我在activityInstance.OwnerId中设置的所有者

The above does not work, the activity owner is defaulting to my crm user account and is not updated to reflect the owner I'm setting in activityInstance.OwnerId

任何帮助将不胜感激。

推荐答案

无法通过更新更改所有者。您必须使用 AssignRequest (或内置的分配步骤,请参见屏幕截图)

The owner can't be changed by update. You have to use the AssignRequest (or the built-in Assign-step, see screenshot)

查看此答案 https://stackoverflow.com/a/7746205/315862

这篇关于设置自定义活动的OwnerId的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆