I got this error when I try to reopen appointment: "Cannot update Closed or Cancelled Activity" here is my code:
var connectionString = ConfigurationManager.ConnectionStrings["crmConnection"].ConnectionString;
var conn = CrmConnection.Parse(connectionString);
var service = new OrganizationService(conn);
var stateRequest = new SetStateRequest
{
State = new OptionSetValue(0),
Status = new OptionSetValue(1),
EntityMoniker = entity.ToEntityReference()
};
service.Execute(stateRequest);
I'm getting the entity from RetrieveMultiple(query)
where StateCode
is "Cancel" or "Complete". I run this code in a Console Application and get that error.
PS: I wrote my code in the new version but I got this error again:
entity.SetAttributeValue<OptionSetValue>("statecode", 0);
entity.SetAttributeValue<OptionSetValue>("statuscode", 1);
var request = new UpdateRequest { Target = entity };
var response = (UpdateResponse)_organizationService.Execute(request);