web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Update Appointment status from a plugin

(0) ShareShare
ReportReport
Posted on by

Hi Experts ,

I want to close an appointment as completed using a plugin but it gives me the following error 

327885.Capture.PNG

at this lines the code fire the error 

AppointmentRecord["statuscode"] = new OptionSetValue(1);
AppointmentRecord["statuscode"] = new OptionSetValue(3);
service.Update(AppointmentRecord);

*This post is locked for comments

I have the same question (0)
  • Verified answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Martina,

    Use SetStateRequest to update the status -

    please find below reference -

    msdn.microsoft.com/.../microsoft.crm.sdk.messages.setstaterequest.aspx

    lakshmanindian.wordpress.com/.../close-activities-in-crm-2011

  • Verified answer
    lokesh@dynamisity Profile Picture
    95 on at

    Hi Martina,

    Use below code it i hope it will help you

    var setAppointmentStateReq = new SetStateRequest

               {

                   EntityMoniker = new EntityReference(Appointment.EntityLogicalName,

                       _appointmentId),

                   State = new OptionSetValue((int)AppointmentState.Completed),

                   Status = new OptionSetValue((int)appointment_statuscode.Completed)

               };

               _serviceProxy.Execute(setAppointmentStateReq);

    Thanks

    Lokesh

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Martina,

    You have used the same field for both the statement. It should be

    AppointmentRecord["statecode"] = new OptionSetValue(1);

    AppointmentRecord["statuscode"] = new OptionSetValue(3);

    Hope this helps.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans