I was trying to set a contract state from Active to Draft using the code below:
SetStateRequest setState = new SetStateRequest();
setState.EntityMoniker = new EntityReference();
setState.EntityMoniker.Id = contractId;
setState.EntityMoniker.Name = "Contract";
setState.EntityMoniker.LogicalName = "contract";
setState.State = new OptionSetValue(0);
setState.Status = new OptionSetValue(1);
SetStateResponse setStateResponse = (SetStateResponse)service.Execute(setState);
My aim is to update an active contract, but to do that I need to have it in Draft state to update it and then put it back to Active, when updated. I would really much appreciate if somone could help me out here.
The plugin right now is firing the following error: "The target state is invalid. The target state may not exist or the system does not allow changing to the target state from the current state. Please check the documentation on this state change request"