Microsoft Exchange integration via Apex class#

Besides custom API endpoints, Revenue Grid can integrate with Microsoft Exchange through dedicated Apex class methods.

Microsoft Exchange calendar actions performed using Apex class methods#

The Apex integration methods support the following operations:

  • Retrieve calendar availability from Microsoft Exchange calendars

  • Create calendar appointments in Microsoft Exchange

  • Delete calendar appointments from Microsoft Exchange

  • Retrieve attendees’ unavailable time slots

  • Reserve selected meeting time slots

  • Verify synchronization results and return troubleshooting error codes

Note

All date and time values in requests and responses use the ISO 8601 format:

YYYY-MM-DDThh:mm:ssZ

All dates and times are processed in the GMT time zone.

Access authorization token#

Access to Microsoft Exchange data is authorized using a Revenue Grid access token generated by Context Sync.

For more details, see About Context Sync.

Apex class methods#

Method getTimeSlotsFromOutlook#

Retrieves attendees’ availability data from Microsoft Exchange calendars.

Parameters#

Parameter

Type

Description

startDateTime

Datetime

Start date and time of the availability range

endDateTime

Datetime

End date and time of the availability range

emailsToCheckAvailability

List of strings

List of attendee email addresses in the same Microsoft Exchange organization

accessToken

String

Access token generated by Context Sync

tenant

String

Revenue Grid tenant URL

Example implementation#

global static void getTimeSlotsFromOutlook(
    Datetime startDateTime, 
    Datetime endDateTime, 
    List<String> emailsToCheckAvailability, 
    String accessToken, 
    String tenant
) {
    HttpResponse resp = request(
        getUrl(startDateTime, endDateTime, tenant),
        'POST',
        getAuthHeader(accessToken),
        getBodyAvailability(emailsToCheckAvailability),
        'getTimeSlots',
        null,
        'SM001_getTimeSlotsMock'
    );

    System.debug('resp.getBody(): ' + resp.getBody());
}

Method createOutlookEvent#

Creates calendar appointments in Microsoft Exchange.

Parameters#

Parameter

Type

Description

eventToCreate

Event

Event object containing appointment properties

accessToken

String

Access token generated by Context Sync

tenant

String

Revenue Grid tenant URL

Example implementation#

global static void createOutlookEvent(
    Event eventToCreate, 
    String accessToken, 
    String tenant
) {
    try {
        HttpResponse resp = request(
            getUrlMeeting(tenant),
            'POST',
            getAuthHeader(accessToken),
            getBody(eventToCreate, 'CREATE'),
            'meeting',
            null,
            'SM001_getTimeSlotsMock'
        );
    } catch (Exception e) {
        System.debug('Error: ' + e.getMessage() + ' ' + e.getStackTraceString());
    }
}

Method deleteOutlookEvent#

Deletes calendar appointments from Microsoft Exchange.

Parameters#

Parameter

Type

Description

eventToDelete

Event

Event object containing appointment properties

accessToken

String

Access token generated by Context Sync

tenant

String

Revenue Grid tenant URL

Example implementation#

global static void deleteOutlookEvent(
    Event eventToDelete, 
    String accessToken, 
    String tenant
) {
    try {
        HttpResponse resp = request(
            getUrlMeeting(tenant),
            'DELETE',
            getAuthHeader(accessToken),
            getBody(eventToDelete, 'DELETE'),
            'meeting',
            null,
            'SM001_getTimeSlotsMock'
        );
    } catch (Exception e) {
        System.debug('Error: ' + e.getMessage() + ' ' + e.getStackTraceString());
    }
}

Appointment properties in JSON format#

The following JSON payload structures are used by Apex integration methods when creating or deleting Microsoft Exchange appointments.

Create appointment#

The following request body structure is used to create a calendar appointment in Microsoft Exchange.

Request body#

Property

Type

Description

id

string

Unique identifier of the appointment

organizerEmail

string

Email address of the event organizer

body

string

Appointment description

subject

string

Appointment subject

location

string

Appointment location

startTime

string (ISO 8601 UTC timestamp)

Appointment start date and time in ISO 8601 format

endTime

string (ISO 8601 UTC timestamp)

Appointment end date and time in ISO 8601 format

salesforceCorrelationId

string

Technical identifier generated by Salesforce for troubleshooting and request tracing

attendees

array of objects

List of appointment attendees

attendees object#

Property

Type

Description

email

string

Email address of the attendee

isRequired

boolean

Indicates whether the attendee is required or optional

Sample request#

{
    "id": "18p09032002jmvP11",
    "organizerEmail": "[email protected]",
    "body": "Agenda: 1, 2, 3",
    "subject": "Project Progress Update 2",
    "location": "Meeting Room 1",
    "startTime": "2022-02-04T01:00:00.000Z",
    "endTime": "2022-02-04T02:00:00.000Z",
    "salesforceCorrelationId": "16bf7d3b-2055-4f70-bnfd-b0061a38ad1f",
    "attendees": [
        {
            "email": "[email protected]",
            "isRequired": "true"
        }
    ]
}

Delete item#

The following request body structure is used to delete a calendar item from Microsoft Exchange.

Request body#

Property

Type

Description

id

string

Unique identifier of the appointment

organizerEmail

string

Email address of the event organizer

attendees

array of strings

List of attendee email addresses

Sample request#

{
    "id": "08p09103202jmvP11",
    "organizerEmail": "[email protected]",
    "attendees": [
        "[email protected]"
    ]
}