Out of Office API

Simon Maskell Updated by Simon Maskell

The DE Apex API includes methods to create and delete out of office entries.

Create Out of Office Entries

global static Map<String, Id> createOutOfOffices(Set<String> userIds, OutOfOfficeDTO outOfOffice)

Creates new out of office entries for each of the users provided using the details defined in the OutOfOfficeDTO parameter. The response will be a map of user ids to the id of the out of office entry created, these ids could then be used for deletion at a later date.

Example

Creates a new out of office entry for the 1st May from 9am to 5pm for two users.

n2de.OutOfOfficeDTO outOfOffice = new n2de.OutOfOfficeDTO();
outOfOffice.startDate = Date.newInstance(2023, 5, 1);
outOfOffice.startTime = Time.newInstance(9, 0, 0, 0);
outOfOffice.endDate = Date.newInstance(2023, 5, 1);
outOfOffice.endTime = Time.newInstance(17, 0, 0, 0);
outOfOffice.reason = 'Public Holiday';
outOfOffice.timezone = 'Europe/London';

String andyId = // Andy's User.Id;
String barclayId = // Barclay's User.Id;
Set<String> userIds = new Set<String>{ andyId, barclayId };

Map<String, Id> results = n2de.GlobalAPIOutOfOffice.createOutOfOffices(userIds, outOfOffice);

  • The user ids are required and need to be valid, active, users who are members of one or more teams
  • The start date and end date are required
  • The start time and end time are optional, if not provided the start/end is considered a full day
  • The reason is required and cannot be more than 80 characters
  • The timezone is required and needs to be a valid Salesforce timezone id

 Delete Out of Office Entry

global static void deleteOutOfOffice(Id outOfOfficeId)

Deletes the provided out of office entry.

Example

The below example creates an out of office entry for two users, then uses the results of that to delete one of those entries for Andy.

n2de.OutOfOfficeDTO outOfOffice = new n2de.OutOfOfficeDTO();
outOfOffice.startDate = Date.newInstance(2023, 5, 1);
outOfOffice.endDate = Date.newInstance(2023, 5, 1);
outOfOffice.reason = 'Public Holiday';
outOfOffice.timezone = 'Europe/London';

String andyId = // Andy's User.Id;
String barclayId = // Barclay's User.Id;
Set<String> userIds = new Set<String>{ andyId, barclayId };

Map<String, Id> results = n2de.GlobalAPIOutOfOffice.createOutOfOffices(userIds, outOfOffice);

Id outOfOfficeId = results.get(andyId);

n2de.GlobalAPIOutOfOffice.deleteOutOfOffice(outOfOfficeId);

  • The out of office id is required and needs to be valid

How did we do?

Out of Office API Parameters

Contact