> ## 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.

# How to create an invitation (data layer)

> How to create an invitation using entities at the NetServer data layer.

After creating an appointment you may need to [invite members][2]. The following example demonstrates how this is done.

```csharp theme={null}
using SuperOffice.CRM.Entities;
using SuperOffice.CRM.Rows;
using SuperOffice.Data;
using SuperOffice;
using(SoSession mySession = SoSession.Authenticate("SAL0", ""))
{
  //Create a New Appointment
  Appointment appointmentOne = Appointment.CreateNew();
  appointmentOne.SetDefaults();
  appointmentOne.AlldayEvent = 1;
  appointmentOne.DoBy = DateTime.Now.AddHours(8);
  appointmentOne.Task = TaskRow.GetFromIdxTaskId(14);
  appointmentOne.AppointmentText = TextRow.CreateNew();
  appointmentOne.AppointmentText.Text = "This is a Project Meeting";

  //Retrieve a person to invite
  Person invitee = Person.GetFromIdxPersonId(5);

  //Add attendee to the Appointment
  SuperOffice.CRM.Services.ParticipantInfo[] participants = new SuperOffice.CRM.Services.ParticipantInfo[1];
  participants[0] = new SuperOffice.CRM.Services.ParticipantInfo();

  //Set the properties of the attendee
  participants[0].AssociateId = invitee.AssociateId;
  participants[0].PersonId = invitee.PersonId;
  participants[0].SendEmail = false;
  RecurrenceUpdateMode recurrenceMode = RecurrenceUpdateMode.OnlyThis;

  //Add the appointment to the appointmentMatrix
  AppointmentMatrix appType = new AppointmentMatrix(appointmentOne, recurrenceMode);
  appType.AddParticipant(participants);

  //Save the appointment
  appType.Save();
}
```

In this example, we have initially created an appointment and set certain properties of it.

## Attendees

A `Person` entity is used for adding as a attendee to this appointment.

In the latter part of the example, we have set some properties of the attendee such as `AssociateId`, `PersonId`, and `SendEmail`. You can create an array of [ParticipantInfo][4] as we have done above.

## AppointmentMatrix

An instance of the `AppointmentMatrix` is created by passing the newly created appointment. You can add the attendees to the matrix by using the `AddParticipant` method.

When the `AppointmentMatrix` is saved, 2 records will be added to the [appointment table][1]:

* One corresponding to the creator of the appointment
* One referring to the attendee

If we have added more attendees, more records will be entered into the `appointment` table.

## See also

* [Appointment table][1]
* [Invitations][2]

[1]: ../../../../database/tables/appointment

[2]: ../../../../diary/learn/invitation/index

[4]: /en/api/reference/webapi/SuperOffice.WebApi.Data.ParticipantInfo


## Related topics

- [How to create an invitation (services)](/en/api/web-services/howto/diary/create-invitation-services.md)
- [How to accept an invitation (services)](/en/api/web-services/howto/diary/accept-invitation-services.md)
- [Create invitation](/en/automation/crmscript/howto/diary/create-invitation.md)
- [Get a contact through the services layer](/en/api/web-services/howto/company/get-contact-via-services-layer.md)
- [How to link a sale to a follow-up (services)](/en/api/web-services/howto/sale/link-sale-to-appointment.md)
- [How to add members to a static selection using entities layer](/en/api/search/selection/entity/add-member-to-static-selection-entities.md)
- [How to accept an invitation](/en/automation/crmscript/howto/diary/accept-invitation.md)
