I need to change the owner of an appointment record when creating a new appointment. I'm using a plugin for the create message and i've found this code to assign a new owner to the appointment:
entity = context.PostEntityImages["PostImage"];
......
AssignRequest request = new AssignRequest();
//request.RequestName
request.Assignee = new EntityReference("systemuser", owners.ToList()[0].Id);
request.Target = new EntityReference(Appointment.EntityLogicalName, entity.Id);
service.Execute(request);
But when I test this i get the following error: Invalid Argument: There should be only one owner party for an activity
I guess i have to remove the current owner first and then assign the new owner. But how can i do this?
Thanks for any help!