Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Change Appointment Status and StatusReason

Posted on by Microsoft Employee

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

  • Suggested answer
    Vipin J Profile Picture
    Vipin J 1,583 on at
    RE: Change Appointment Status and StatusReason

    Changing statuscode (Status Reason) for an appointment and it will automatically impact statecode (Status)

    Refer here for common appointment operation done using web api

    https://vjcity.blogspot.com/2020/06/appointment-in-dynamic-crm-using-web-api.html

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Change Appointment Status and StatusReason

    Hi Martina Mounir,

    Can you please check in audit history, whether is there any process revert status in previous state. Also use tracing service in plugin so that you can check plugin trace entity as well.

    Hope this help you.

    Regards,

    Pravin

  • Verified answer
    Prashant_ Profile Picture
    Prashant_ 1,040 on at
    RE: Change Appointment Status and StatusReason

    It is possible to change appointment status from plugin.There is no problem with code.Try to debug plugins since you don't get any error message then it might be related if condition or plugin not fire on update of field .

    just update 

    EntityMoniker = new EntityReference(entitylogicalname, recordid),

    following blog is more  useful if you have issue 

    www.magnetismsolutions.com/.../Change_the_Status_of_Record_using_Plugin_in_Dynamics_CRM_2011.aspx

    hope this will help you 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans