Hi Experts,
I want to ask if is it applicable to change the status and status reason for an appointment using a custom plugin or not ?
I wrote down the following method to change the appointment status and when the plugin fires it neither give me error nor change the record status !!!!
public static void SetStatusComplete(string entityName, Guid recordId, IOrganizationService organizationService)
{
var cols = new ColumnSet(new[] { "statecode", "statuscode" });
//Check if it is Active or not
var entity = organizationService.Retrieve(entityName, recordId, cols);
if (entity != null && entity.GetAttributeValue<OptionSetValue>("statecode").Value == 0)
{
//StateCode = 1 and StatusCode = 3 for Complete appointment
SetStateRequest setStateRequest = new SetStateRequest()
{
EntityMoniker = new EntityReference
{
Id = recordId,
LogicalName = entityName,
},
State = new OptionSetValue(1),
Status = new OptionSetValue(3)
};
organizationService.Execute(setStateRequest);
}
}
*This post is locked for comments