Setting OwnerId Custom Action

I created a custom CRM activity that I use in my workflow. I use this action as an InArgument for a custom workflow action. In the Execute () method, I try to set the OwnerId of the user CRM activity instance to the system user and call the UpdateObject object in the context object that I created 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 default activity owner runs the crm user account and is not updated to reflect the owner I set in activityInstance.OwnerId

Any help would be greatly appreciated.

+2
source share
1 answer

The owner cannot be changed by updating. You must use AssignRequest (or the built-in Assign-step parameter, see screenshot)

See this answer fooobar.com/questions/662282 / ...

enter image description here

+6
source

All Articles