> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Create an Appointment entity through an entity collection

> How to create an Appointment entity through an entity collection at the NetServer data layer.

The `SuperOffice.CRM.Entities` namespace exposes [entity collections][1] such as `AppointmentCollection` and `PersonCollection`. It is therefore possible to create an `Appointment` entity and assign it to the collection and thereby saving the collection the Appointment entity will be saved.

The following example demonstrates the method of doing the above.

## Code

```csharp CS theme={null}
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 the Appointment Entity
  //Assigning basic properties to the Appointment
  newAppointment.Location = "Seminar Room 662";
  newAppointment.EndDate = new DateTime(2007, 3, 4);
  newAppointment.Status = SuperOffice.Data.AppointmentStatus.NotStarted;
  newAppointment.Private = SuperOffice.Data.AppointmentPrivate.Public;
  newAppointment.HasAlarm = 1;
  newAppointment.Alarm = 5;

  //Assigning a Row type property to the Appointment Entity
  newAppointment.Associate = SuperOffice.CRM.Rows.AssociateRow.GetFromIdxAssociateId(100);

  //Assigning an Entity type property to the Appointment
  newAppointment.Contact = Contact.GetFromIdxContactId(20);
  newAppointment.Person = Person.GetFromIdxPersonId(10);

  //Instantiating the Appointment Collection
  AppointmentCollection newAppCol = AppointmentCollection.CreateNew();

  //Adding the Contact Entity to the Collection and Saving the Collection
  newAppCol.Add(newAppointment);
  newAppCol.Save();
}
```

## Walk-through

After creating an instance of the `Appointment` entity and assigning the desired values the next step is to assign the created appointment to the collection.

First, we create an `AppointmentCollection` and then add the appointment to the collection using the `Add` method.

Once it has been added, the collection can be saved:

```csharp CS theme={null}
AppointmentCollection newAppCol = AppointmentCollection.CreateNew();
newAppCol.Add(newAppointment);
newAppCol.Save();
```

[1]: ../../collections


## Related topics

- [Create Appointment Entity From Existing](/en/api/reference/restful/agent/appointment_agent/create-appointment-entity-from-existing.md)
- [Create Default Appointment Entity](/en/api/reference/restful/agent/appointment_agent/create-default-appointment-entity.md)
- [Create Default Appointment Entity By Type](/en/api/reference/restful/agent/appointment_agent/create-default-appointment-entity-by-type.md)
- [Create Default Appointment Entity From Sale Suggestion](/en/api/reference/restful/agent/appointment_agent/create-default-appointment-entity-from-sale-suggestion.md)
- [Create Default Appointment Entity From Project Suggestion](/en/api/reference/restful/agent/appointment_agent/create-default-appointment-entity-from-project-suggestion.md)
- [Create Default Suggested Appointment Entity](/en/api/reference/restful/agent/appointment_agent/create-default-suggested-appointment-entity.md)
- [Create Default Appointment Entity By Type And Associate](/en/api/reference/restful/agent/appointment_agent/create-default-appointment-entity-by-type-and-associate.md)
