locked
Create appointment RRS feed

  • Question

  • hi all,
    when i create an appointment in c# it is created successfully but when i go to calendar i find no appointment,
    when i tried to create it manually i find it in calendar .
    what is the exact fields need to fill when create appointment to make it apperaring in calendar ?


    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, May 11, 2009 8:55 AM

Answers

  • Hi pen_2,

    the following statecode and statuscodes are correct for appointments:
    http://msdn.microsoft.com/en-us/library/bb890230.aspx

    for "Scheduled" the statuscodes 5 (Busy) and 6 (Out of Office) are correct.

    You used the value "-1", so I think here could be a reasong why the appointment is not visible.

    Best regards,
    Jürgen
    Jürgen Beck

    Dipl. Kfm./Wirtschaftsinformatik
    MVP, MCSD.NET, MCITP DBA, MCDBA, MCSE
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified CRM Developer
    Microsoft Certified Trainer

    ComBeck IT Services & Business Solutions
    Microsoft Gold Certified Partner
    Microsoft Small Business Specialist

    Developing & Supporting Business Applications from small business to big enterprises covering scores of sectors

    http://www.combeck.de
    Monday, May 11, 2009 10:03 AM
    Moderator
  • Appointment and task are not in parent/child relation. Appointment is on the same level as task or fax or e-mail entity so proper relation is for example appointment:activitypointer(1:N) and activitypointer:incident(1:N).
    • Marked as answer by Dany85 Monday, May 11, 2009 2:08 PM
    Monday, May 11, 2009 2:05 PM

All replies

  • Hi Dany,

    do you mean the web-based CRM-calendar or the calendar of Outlook?

    If the appointment is somehow related to you (owner, organizer, required, optional) is should be display in the web-based CRM-calendar immediately and after some minutes (after the synchronization) in the calendar of Outlook.

    Best regards,
    Jürgen
    Jürgen Beck

    Dipl. Kfm./Wirtschaftsinformatik
    MVP, MCSD.NET, MCITP DBA, MCDBA, MCSE
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified CRM Developer
    Microsoft Certified Trainer

    ComBeck IT Services & Business Solutions
    Microsoft Gold Certified Partner
    Microsoft Small Business Specialist

    Developing & Supporting Business Applications from small business to big enterprises covering scores of sectors

    http://www.combeck.de
    Monday, May 11, 2009 9:06 AM
    Moderator
  • i got it i shoud to set organizer.
    thanks Jürgen Beck
    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, May 11, 2009 9:08 AM
  • Hi, Deny. When you are creating appointment programmaly you have to fill Due field and to see this appontment in calendar and you must be related to this appointment (owner, organizer, required, optional).

    Truth opens to prepared mind. My blog - http://a33ik.blogspot.com
    Monday, May 11, 2009 9:10 AM
    Moderator
  • Hi
        Here is code sample:

    DynamicEntity dynent_activityparty = new DynamicEntity("activityparty");
                dynent_activityparty.Properties.Add(new LookupProperty("partyid", new Lookup(EntityName.systemuser.ToString(), new Guid("{2754B2CF-1224-DE11-9A53-00155D037105}"))));
                dynent_activityparty.Properties.Add(new PicklistProperty("participationtypemask", new Picklist(ParticipationType.Resource)));
                DynamicEntity dynent_appointment = new DynamicEntity("appointment");

                dynent_appointment.Properties.Add(new StringProperty("description", "Book test"));
                dynent_appointment.Properties.Add(new CrmDateTimeProperty("scheduledstart", CrmDateTime.FromUser(DateTime.Parse("2009-05-21 12:30"))));
                dynent_appointment.Properties.Add(new CrmDateTimeProperty("scheduledend", CrmDateTime.FromUser(DateTime.Parse("2009-05-21 13:30"))));
                dynent_appointment.Properties.Add(new StringProperty("location","Office"));
                dynent_appointment.Properties.Add(new StringProperty("subject","Testing book appointment"));
                dynent_appointment.Properties.Add(new DynamicEntityArrayProperty("requiredattendees", new DynamicEntity[] { dynent_activityparty }));
                dynent_appointment.Properties.Add(new StatusProperty("statuscode", new Status(-1)));
                dynent_appointment.Properties.Add(new StateProperty("statecode", "Scheduled"));
               
                TargetScheduleDynamic target = new TargetScheduleDynamic();
                target.Entity = dynent_appointment;
                BookRequest book = new BookRequest();
                book.Target = target;
                BookResponse bookresp = (BookResponse)crmService.Execute(book);


    Hope it helps
    everything is a matter of probability...
    Monday, May 11, 2009 9:21 AM
  • Hi pen_2,

    the following statecode and statuscodes are correct for appointments:
    http://msdn.microsoft.com/en-us/library/bb890230.aspx

    for "Scheduled" the statuscodes 5 (Busy) and 6 (Out of Office) are correct.

    You used the value "-1", so I think here could be a reasong why the appointment is not visible.

    Best regards,
    Jürgen
    Jürgen Beck

    Dipl. Kfm./Wirtschaftsinformatik
    MVP, MCSD.NET, MCITP DBA, MCDBA, MCSE
    Microsoft Certified Business Management Solutions Professional
    Microsoft Certified CRM Developer
    Microsoft Certified Trainer

    ComBeck IT Services & Business Solutions
    Microsoft Gold Certified Partner
    Microsoft Small Business Specialist

    Developing & Supporting Business Applications from small business to big enterprises covering scores of sectors

    http://www.combeck.de
    Monday, May 11, 2009 10:03 AM
    Moderator
  • Hi Jurgen
       Value "-1" states for default. Why do you think that I had a problem with not visible appointment? Thread is started by Dany85 not me. I'm using this code in some sheduling customizations and it is working without any problems.

    EDIT:
    Of course you must check 'bookresp.ValidationResult.ValidationSuccess' if request was succesfull.
    Monday, May 11, 2009 10:09 AM
  • why this code does not work ?


     appointment myappointment = new appointment();
                myappointment.subject = "test";
    
                myappointment.statuscode = new Status();
                myappointment.statuscode.Value = 5;
                CrmBoolean TRUE = new CrmBoolean();
                TRUE.Value = true;
                myappointment.isalldayevent = TRUE;
                myappointment.scheduledstart = new CrmDateTime();
                myappointment.scheduledstart.Value = DateTime.Now.AddDays(1).ToLongDateString();
                myappointment.scheduledend = new CrmDateTime();
                myappointment.scheduledend.Value = DateTime.Now.AddDays(1).ToLongDateString();
    
                service.Create(myappointment);
    i've got error message " server unable to process request"
    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, May 11, 2009 11:48 AM
  • Hi, Dany.

    Try add following code to server call to see Exception Source:


    try
    {
    service.Create(myappointment);
    }
    catch(SoapException ex)
    {
    throw new Exception(ex.Detail.InnerText);
    }
    


    Truth opens to prepared mind. My blog - http://a33ik.blogspot.com
    Monday, May 11, 2009 11:50 AM
    Moderator
  • Hi Dany
        First problem is in statuscode/statecode. When you create apppointment you have default state set as 'open' and '5' is wrong status for this state. Second problem may be in setting period, change this:

    myappointment.scheduledstart = new
     CrmDateTime();<br/>
    myappointment.scheduledstart.Value = DateTime.Now.AddDays(1).ToLongDateString();
    myappointment.scheduledend = new CrmDateTime();<br/> myappointment.scheduledend.Value = DateTime.Now.AddDays(1).ToLongDateString();
    To this:
    myappointment.scheduledstart = CrmDateTime.FromUser(DateTime.Now.AddDays(1));
    myappointment.scheduledend = CrmDateTime.FromUser(DateTime.Now.AddDays(1));
    To see this appointment in calendar you should also set 'requiredattendees' property.

    Monday, May 11, 2009 12:16 PM
  • after creating appointment successfully i've error message " Creating Entity with an invalid parent. Entity: Task, ReferencingAttribute:regardingobjectid  Platform"


    appointment myappointment = new appointment();
    
                    myappointment.subject = "test1";
    
    
    
                    activityparty organizer = new activityparty();
    
                    organizer.partyid = new Lookup();
    
                    organizer.partyid.type = EntityName.systemuser.ToString();
    
                    organizer.partyid.Value = new Guid("9BF5E0DF-65C1-DC11-B67A-0003FFBB057D");
    
                    myappointment.organizer = new activityparty[] { organizer };
    
    
    
    
    
                    myappointment.scheduledstart = new CrmDateTime();
    
                    myappointment.scheduledstart.Value = DateTime.Now.AddDays(2).ToLongDateString();
    
                    myappointment.scheduledend = new CrmDateTime();
    
                    myappointment.scheduledend.Value = DateTime.Now.AddDays(2).AddHours(23).ToLongDateString();
    
    
    
                    Guid appointment = service.Create(myappointment);
    
    
    
    
    
                    task oTask = new task();
    
                    oTask.subject = "Payment[1]";
    
                    Owner ownerid = new Owner();
    
                    ownerid.name = "my name";
    
                    ownerid.type = EntityName.systemuser.ToString();
    
    
    
                    oTask.regardingobjectid = new Lookup();
    
                    oTask.regardingobjectid.type = EntityName.appointment.ToString();
    
                    oTask.regardingobjectid.Value = new Guid();
    
                    oTask.regardingobjectid.Value = appointment;
    
    
    
                    ownerid.Value = new Guid("9BF5E0DF-65C1-DC11-B67A-0003FFBB057D");
    
                    oTask.ownerid = ownerid;
    
                    oTask.scheduledstart = new CrmDateTime();
    
                    oTask.scheduledstart.Value = DateTime.Now.ToLongDateString();
    
                    oTask.scheduledend = new CrmDateTime();
    
                    oTask.scheduledend.Value = DateTime.Now.AddDays(2).ToLongDateString();
    
                    service.Create(oTask);
    
    

    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, May 11, 2009 1:45 PM
  • Appointment and task are not in parent/child relation. Appointment is on the same level as task or fax or e-mail entity so proper relation is for example appointment:activitypointer(1:N) and activitypointer:incident(1:N).
    • Marked as answer by Dany85 Monday, May 11, 2009 2:08 PM
    Monday, May 11, 2009 2:05 PM
  • oops, i forgot this idea
    foreach(object HeartBeat in me.heart.Beats) messageBox.show("I miss u !!")
    Monday, May 11, 2009 2:09 PM