How to accept an invitation (services)
This example shows how to accept an invitation through the NetServer services layer with just a few code statements.
We use NetServer providers (plugins created with a Factory class) to retrieve information on invitations for a specific associate.
IArchiveProvider
is the external standard interface of archive providers exposed to the service layer and the world in general. The interface aggregates the extensible and provider properties of classes such as ActivityArchiveProvider
, ProjectMemberProvide
, and InvitationProvider
. This acts as an intermediate stage between the pure property interface and the actual provider class that has queries.
After getting an overview by listing invitations for an associate, we plan to accept the invitation with appointmentId = 150
. This is done using the AppointmentAgent from the SuperOffice.CRM.Services
namespace. All calls to the agent correspond to a web service services call.
Code
using SuperOffice;
using SuperOffice.CRM.ArchiveLists;
using SuperOffice.CRM.Services;
using(SoSession newSession = SoSession.Authenticate("sam", "sam"))
{
//Createing an instance of the Appointment Agent
using(AppointmentAgent newAppAgt = new AppointmentAgent())
{
//Accepting the invitation
AppointmentEntity newAppEnt = newAppAgt.Accept(150,SuperOffice.Data.RecurrenceUpdateMode.OnlyThis);
}
}
Walk-through
In the example, we have created an instance of the AppointmentAgent
and called its Accept
method passing the appointmentId
and the UpdateMode
.
Output:
associate/contactFullName date endDate appointmentId
StateZeroDatabase [D:07/05/2007] [D:07/05/2007] [I:186]
StateZeroDatabase [D:07/26/2007] [D:07/26/2007] [I:179]
StateZeroDatabase [D:04/28/2007] [D:04/28/2007] [I:172]
StateZeroDatabase [D:06/14/2007] [D:06/14/2007] [I:161]
The reason that the details of an invitation with appointmentId
150 is not shown (like it did when we listed it), is that once the invitation has been accepted it becomes a normal appointment without the invitation status set and it can no longer be retrieved by using the InvitationProvider.