Create an Appointment entity
Using the Appointment
entity exposed in the SuperOffice.CRM.Entities
namespace is one of the easiest ways to create an appointment, as shown in the example below.
Code
using SuperOffice.CRM.Entities;
using SuperOffice;
using(SoSession mySession = SoSession.Authenticate("sam", "sam"))
{
//Create an Appointment Entity
Appointment newAppointment = Appointment.CreateNew();
//Setting the Default values for the Appointment
newAppointment.SetDefaults();
//Assigning values to the individual properties of theAppointment Entity
//Assigning basic properties to the Appointment
newAppointment.Location = "Seminar Room 123";
newAppointment.EndDate = new DateTime(2007,3, 4);
newAppointment.Status = SuperOffice.Data.AppointmentStatusNotStarted;
newAppointment.Private = SuperOffice.Data.AppointmentPrivatePublic;
newAppointment.HasAlarm = 1;
newAppointment.Alarm = 5;
//Assigning a Row type property to the Appointment Entity
newAppointment.Associate = SuperOffice.CRM.Rows.AssociateRowGetFromIdxAssociateId(100);
//Assigning an Entity type property to the Appointment
newAppointment.Contact = Contact.GetFromIdxContactId(20);
newAppointment.Person = Person.GetFromIdxPersonId(10);
//Saving the Created Appointment Entity
newAppointment.Save();
}
Walk-through
After an SoSession
has been created, we proceed on to creating an appointment.
To create an appointment, it is required to create an instance of the Appointment
entity using the CreateNew
method exposed in the Associate
class, after which the default values for the entity will be set using the SetDefaults
method like this:
Appointment newAppointment = Appointment.CreateNew();
newAppointment.SetDefaults();
The next section of the code shows how values are assigned to properties exposed by the entity. Pay attention to how we assign the Alarm
property:
newAppointment.HasAlarm = 1;
newAppointment.Alarm = 5;
The HasAlarm
property should be assigned first before the value for the Alarm
property is assigned.
Once the required values to the properties of the Appointment
entity have been added or assigned it could be saved with the Save
method:
newAppointment.Save();