Setting OwnerId of a custom activity

孤街醉人 提交于 2019-12-12 20:52:32

问题


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

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

Any help would be much appreciated.


回答1:


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

See this answer https://stackoverflow.com/a/7746205/315862



来源:https://stackoverflow.com/questions/8529535/setting-ownerid-of-a-custom-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!