Professional Services Automation Apex API Developer Reference

pse.TeamScheduleService

global with sharing class TeamScheduleService

This class contains the Team Schedule API implementation, including sub-classes for team schedule creation requests.

Methods

createTeamScheduleFromTemplate

global Set<Id> createTeamScheduleFromTemplate(Id teamId, List<pse.TeamScheduleService.CreateTeamScheduleFromTemplateRequest> createTeamScheduleFromTemplateRequest)

This method creates a new team schedule from a team schedule template using the details provided from the CreateTeamScheduleFromTemplateRequest list.
Operations are performed as follows:
• Inserts new team schedules.
• Inserts new team schedule time slots.

Input Parameters

Name Type Description
teamId Id The team id of the team schedule.
createTeamScheduleFromTemplateRequest List<pse.TeamScheduleService.CreateTeamScheduleFromTemplateRequest> A list of CreateTeamScheduleFromTemplateRequest objects.

Exceptions Thrown

Value Description
TeamScheduleDetailException This exception occurs when a user sends a request with an invalid team schedule template id.

Return Value

This service returns the ids of the newly created team schedules.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

// This is sample code for creating a team schedule from a team schedule template using the TeamScheduleService API.
static void testCreateTeamScheduleFromTemplate()
{
    /**
     * The CreateTeamScheduleFromTemplateRequest class extends the CreateTeamScheduleRequest so that you can create an instance of CreateTeamScheduleFromTemplateRequest.
     * Here we are creating two team schedules for team1 on 3 March and 4 March by using the team schedule template.
     */
    Date schDate1, schDate2;
    Id teamId = team1.id;
    Id templateId = template1.Id;
    schDate1 = date.valueOf('2017-03-03');
    schDate2 = date.valueOf('2017-04-03');
    
    // Creates an instance of the CreateTeamScheduleFromTemplateRequest class with a default constructor.
    TeamScheduleService.CreateTeamScheduleFromTemplateRequest createSchReq1 = new TeamScheduleService.CreateTeamScheduleFromTemplateRequest(teamId, schDate1, templateId);
    TeamScheduleService.CreateTeamScheduleFromTemplateRequest createSchReq2 = new TeamScheduleService.CreateTeamScheduleFromTemplateRequest(teamId, schDate2, templateId);

    // Creates a list of CreateTeamScheduleFromTemplateRequest objects.
    list<TeamScheduleService.CreateTeamScheduleFromTemplateRequest> listCs = new list<TeamScheduleService.CreateTeamScheduleFromTemplateRequest>();
    listCs.add(createSchReq1);
    listCs.add(createSchReq2);
    
    // Creates an instance of the TeamScheduleService class.
    TeamScheduleService cls = new TeamScheduleService();
    // Calls the createTeamScheduleFromTemplate API method.
    Set<Id> result = cls.createTeamScheduleFromTemplate(teamId, listCs);
    System.assertEquals(2, result.size());
}

createCustomTeamSchedule

global Set<Id> createCustomTeamSchedule(Id teamId, List<pse.TeamScheduleService.CreateCustomTeamScheduleRequest> createCustomTeamScheduleRequest)

This method creates a custom team schedule using details provided from the CreateCustomTeamScheduleRequest list.
Operations performed as follows.
• Inserts new team schedules.
• Inserts new team schedule time slots.

Input Parameters

Name Type Description
teamId Id The team id of the team schedule.
createCustomTeamScheduleRequest List<pse.TeamScheduleService.CreateCustomTeamScheduleRequest> An object of CreateCustomTeamScheduleRequest.

Exceptions Thrown

Value Description
TeamScheduleDetailException This exception occurs when a user sends a request with zero time slots or invalid time slot data.

Return Value

This service returns the ids of the newly created team schedules.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

// This is sample code for creating a custom team schedule using the TeamScheduleService API.
static void testCreateCustomTeamScheduleRequest()
{
    /**
     * The CreateCustomTeamScheduleRequest class extends the CreateTeamScheduleRequest so that you can create an instance of CreateCustomTeamScheduleRequest.
     * Here we are creating two custom team schedules for team1 on 3 March and 4 March.
     */
    Date schDate1, schDate2;
    Id teamId = team1.id;
    Id scheduleSlotTypeId = scheduleSlotType1.id;
    schDate1 = date.valueOf('2017-03-03');
    schDate2 = date.valueOf('2017-04-03');
    
    // Creates a list of TeamScheduleSlotDetail objects.
    List<TeamScheduleService.TeamScheduleSlotDetail> slots = new List<TeamScheduleService.TeamScheduleSlotDetail>();
    
    // Creates an instance of the TeamScheduleSlotDetail class with a default constructor and required properties.
    TeamScheduleService.TeamScheduleSlotDetail s1 = new TeamScheduleService.TeamScheduleSlotDetail('s1', '4:00am', '4:30am', 4.25, 6, scheduleSlotTypeId);
    TeamScheduleService.TeamScheduleSlotDetail s2 = new TeamScheduleService.TeamScheduleSlotDetail('s2', '5:00am', '5:30am', 4, 6, scheduleSlotTypeId);
    slots.add(s1);
    slots.add(s2);
    
    // Creates an instance of the CreateCustomTeamScheduleRequest class with a default constructor.
    TeamScheduleService.CreateCustomTeamScheduleRequest createSchReq1 = new TeamScheduleService.CreateCustomTeamScheduleRequest(teamId, schDate1, slots);
    TeamScheduleService.CreateCustomTeamScheduleRequest createSchReq2 = new TeamScheduleService.CreateCustomTeamScheduleRequest(teamId, schDate2, slots);

    // Creates a list of CreateCustomTeamScheduleRequest objects.
    list<TeamScheduleService.CreateCustomTeamScheduleRequest> listCs = new list<TeamScheduleService.CreateCustomTeamScheduleRequest>();
    listCs.add(createSchReq1);
    listCs.add(createSchReq2);
    
    // Creates an instance of TeamScheduleService.
    TeamScheduleService cls = new TeamScheduleService();
    // Calls the createTeamScheduleFromTemplate API method.
    Set<Id> result = cls.createCustomTeamSchedule(teamId, listCs);
    System.assertEquals(2, result.size());
}

pse.TeamScheduleService.CreateTeamScheduleRequest

global inherited sharing abstract class CreateTeamScheduleRequest

The request structure for the CreateTeamScheduleRequest class.

Properties

Name Type Description
TeamId Id The team id associated with the team schedule.
EffectiveDate Date The effective date of the team schedule.

pse.TeamScheduleService.CreateTeamScheduleFromTemplateRequest

global inherited sharing class CreateTeamScheduleFromTemplateRequest extends CreateTeamScheduleRequest

The request structure for creating a team schedule using the team schedule template.

This class extends pse.TeamScheduleService.CreateTeamScheduleRequest

Properties

Name Type Description
TemplateId Id A valid team schedule template id for creating a team schedule.
Slots List<pse.TeamScheduleService.TeamScheduleSlotDetail> The list of TeamScheduleSlotDetail objects used to create schedule time slots for team schedule.
teamId String
effectiveDate String

Methods

CreateTeamScheduleFromTemplateRequest

global CreateTeamScheduleFromTemplateRequest(Id teamId, Date effectiveDate, Id templateId)

A default constructor with the minimum required properties.

Input Parameters

Name Type Description
teamId Id The team id.
effectiveDate Date The effective date of team schedule.
templateId Id The team schedule template id to create team schedule.

pse.TeamScheduleService.CreateCustomTeamScheduleRequest

global inherited sharing class CreateCustomTeamScheduleRequest extends CreateTeamScheduleRequest

The request structure for CreateCustomTeamScheduleRequest class.

This class extends pse.TeamScheduleService.CreateTeamScheduleRequest

Properties

Name Type Description
Slots List<pse.TeamScheduleService.TeamScheduleSlotDetail> The list of TeamScheduleSlotDetail objects used to create schedule slots for the team schedule.
teamId String
effectiveDate String

Methods

CreateCustomTeamScheduleRequest

global CreateCustomTeamScheduleRequest(Id teamId, Date effectiveDate, list<pse.TeamScheduleService.TeamScheduleSlotDetail> slots)

A default constructor for the CreateCustomTeamScheduleRequest class with the minimum required properties.

Input Parameters

Name Type Description
teamId Id The team id.
effectiveDate Date The effective date of team schedule.
slots list<pse.TeamScheduleService.TeamScheduleSlotDetail> The list of TeamScheduleSlotDetail objects used to create time slots of a team schedule.

pse.TeamScheduleService.TeamScheduleSlotDetail

global inherited sharing class TeamScheduleSlotDetail

This method is used to map data to its respective DTO.

Properties

Name Type Description
SlotName String The name of the schedule time slot.
StartTime String The start time of the schedule time slot.
EndTime String The end time of the schedule time slot.
Hours Decimal The total hours of the schedule time slot.
Capacity Integer The number of resources required for the schedule time slot.
SlotType Id The id of the schedule slot type for the schedule time slot.

Methods

TeamScheduleSlotDetail

global TeamScheduleSlotDetail(String slotName, String startTime, String endTime, Decimal hours, Integer capacity, Id slotTypeId)

A default constructor with the minimum required properties.

Input Parameters

Name Type Description
slotName String The name of the schedule time slot.
startTime String The start time of the schedule time slot.
endTime String The end time of the schedule time slot.
hours Decimal The total hours of the schedule time slot.
capacity Integer The number of resources required for the schedule time slot.
slotTypeId Id The id of the schedule slot type for the schedule time slot.
© Copyright 2009–2024 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.