locked
issue updating appointment i am reopening RRS feed

  • Question

  • Hi:

    Using a workflow

    I have an appointment that I am trying to update when the save as completed.  I can retrieve the appt no problem I can reopen it no problem

    When I go to update the appt i keep getting "3 is not a valid status code for state code appintmentstate.open on appointment"  Code worked fine in crm 3

    When I open the appt state code is set to 1.  Im not setting it to 3.  However I do notice that the appointment when i create it comes up as scheduled.  Also, when I reopen the appointment as open is still comes up as scheduled versus open.
     
    When I update Im getting the 3 error.  How do I reopen an appt in crm 4?

    Dim OpenAppt As SetStateAppointmentRequest = New SetStateAppointmentRequest

     New Guid(Me.activityid.Value.ToString)

    Dim OpenApptResponse As SetStateAppointmentResponse = CType(crmService.Execute(OpenAppt), SetStateAppointmentResponse)

     

     

    OpenAppt.AppointmentState = AppointmentState.Open
    OpenAppt.AppointmentStatus = 1

    OpenAppt.EntityId = New Guid(Me.activityid.Value.ToString)

     

    Tuesday, August 11, 2009 12:33 PM

Answers

  • Ok so you want to update the appoinment after it is opened..right?

    i think retrive the appoinment one more time after you have re-open sucessfully as follows

               //code to Open Appoinment
                       -----
               // retrive the updated appoinment again so that you get latest object from CRM

              // then use the retrived object (appointment)  to update the values
       

    Also just update the   State (AppointmentState = AppointmentState.Open) and leave status as -1 (OpenAppt.AppointmentStatus = -1)

    see it this works..if not please post the full code and will try to provide solution for the same...
    • Marked as answer by T Bonz Tuesday, August 11, 2009 1:57 PM
    Tuesday, August 11, 2009 1:44 PM

All replies

  • set it to -1 and CRM will set it to right status...following is the example code (i have test and works at my end) but it is in C#

    SetStateAppointmentRequest OpenAppt = new SetStateAppointmentRequest();
                //change the ID here     
                OpenAppt.EntityId = new Guid("D21B86EA-2D4A-DE11-87C4-00237DA4791C");
                OpenAppt.AppointmentState = AppointmentState.Open;
                OpenAppt.AppointmentStatus = -1;
    
                SetStateAppointmentResponse OpenApptResponse = (SetStateAppointmentResponse)incService.Execute(OpenAppt);
                
    hope this helps!!

    Tuesday, August 11, 2009 1:11 PM
  • the appt was reopened fine -- but when i go to update the dynamic entity it just errors out with the "3 is not a valid status code for state code appintmentstate.open on appointment"

    i've eventried setting it scheduled and get the same thing when i go to update it

    Tuesday, August 11, 2009 1:38 PM
  • Ok so you want to update the appoinment after it is opened..right?

    i think retrive the appoinment one more time after you have re-open sucessfully as follows

               //code to Open Appoinment
                       -----
               // retrive the updated appoinment again so that you get latest object from CRM

              // then use the retrived object (appointment)  to update the values
       

    Also just update the   State (AppointmentState = AppointmentState.Open) and leave status as -1 (OpenAppt.AppointmentStatus = -1)

    see it this works..if not please post the full code and will try to provide solution for the same...
    • Marked as answer by T Bonz Tuesday, August 11, 2009 1:57 PM
    Tuesday, August 11, 2009 1:44 PM
  • that got it to update -- thanks alot for your help

    Tuesday, August 11, 2009 1:57 PM