In CRM 2011 I have an Activity entity labelled "activityEntity" in my code. I also have a radio button field named "AssignToCaseOwner" on the Case entity. The Case entity is labelled "sourceCase".
Basically when AssignToCaseOwner is set to Yes, then the Activity will be assigned to the Owner of the Case.
To achieve this I'm using "AssignRequest" method. I was told that I cannot do AssignRequest for all Activities in general, but have to specify Task, Appointment, etc - is that correct?
This is the code that I have, but for some reason the Activity keeps getting assigned to the Case creator. Any suggestion is very much appreciated.
I have a feeling that the Activity Guid was not captured correctly in the Target assignment.
Thanks, -elisabeth
var sourceCaseColumnSet = new ColumnSet(new[] {"ownerid"});
var sourceCaseAttributes = sourceCase.RetrieveEntity<Entity>(service, sourceCaseColumnSet);
// If the ezCase Activity is set to Case Owner
if ((int)assignToCaseOwner == 1)
{
AssignRequest assignCase = new AssignRequest
{
Assignee = new EntityReference("systemuser", (Guid)sourceCaseAttributes.Attributes["ownerid"]),
Target = new EntityReference("activity", new Guid(activityEntity.Id.ToString()))
};
// Execute the AssignRequest
service.Execute(assignCase);