PSA Apex API Developer Reference

pse.TeamScheduleTemplateService

global with sharing class TeamScheduleTemplateService

This class contains a Team Schedule Template API implementation, including sub-classes for team schedule template creation requests. There are sub-classes for team schedule template creation requests.

Methods

createTeamScheduleTemplate

global Set<Id> createTeamScheduleTemplate(Id teamId, List<pse.TeamScheduleTemplateService.CreateTeamScheduleTemplateRequest> createTeamScheduleTemplateRequest)

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

Input Parameters

Name Type Description
teamId Id The team id of the team schedule template.
createTeamScheduleTemplateRequest List<pse.TeamScheduleTemplateService.CreateTeamScheduleTemplateRequest> A list of CreateTeamScheduleTemplateRequest objects.

Exceptions Thrown

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

Return Value

This service returns the ids of the newly created team schedule templates.

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 template using TeamScheduleTemplateService API.
static void testCreateTeamScheduleTemplateRequest()
{                
    /**
     * The CreateTeamScheduleTemplateRequest class extends the TeamScheduleTemplateRequest so that you can create an instance of CreateTeamScheduleTemplateRequest.
     * Here we are creating two team schedule templates for team1.
     */
     
    Id teamId = team1.id;
    
    Team_Schedule_Slot_Type__c slotType = new Team_Schedule_Slot_Type__c( Type__c = 'Weekday, Non-blocking' );
    insert slotType;
        
    // Creates a list of TeamScheduleTemplateSlotDetail objects.
    List<TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail> slots = new List<TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail>();
    
    // Creates an instance of the TeamScheduleTemplateSlotDetail class with a default constructor and required properties.
    TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail s1 = new TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail('s1', '4:00am', '4:30am', 4.25, 6, slotType.Id);
    TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail s2 = new TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail('s2', '5:00am', '5:30am', 4, 6, slotType.Id);
    slots.add(s1);
    slots.add(s2);
    
    // Creates an instance of the CreateTeamScheduleTemplateRequest class with a default constructor.
    TeamScheduleTemplateService.CreateTeamScheduleTemplateRequest createSchTempReq1 = new TeamScheduleTemplateService.CreateTeamScheduleTemplateRequest(teamId, 'Template1', slots);
    TeamScheduleTemplateService.CreateTeamScheduleTemplateRequest createSchTempReq2 = new TeamScheduleTemplateService.CreateTeamScheduleTemplateRequest(teamId, 'Template2', slots);

    // Creates a list of CreateTeamScheduleTemplateRequest objects.
    list<TeamScheduleTemplateService.CreateTeamScheduleTemplateRequest> listSt = new list<TeamScheduleTemplateService.CreateTeamScheduleTemplateRequest>();
    listSt.add(createSchTempReq1);
    listSt.add(createSchTempReq2);
    
    // Creates an instance of the TeamScheduleTemplateService class.
    TeamScheduleTemplateService objTeamSchTempService = new TeamScheduleTemplateService();
    // Calls the createTeamScheduleTemplate API method.
    Set<Id> result = objTeamSchTempService.createTeamScheduleTemplate(teamId, listSt);
    System.assertEquals(2, result.size());
}

pse.TeamScheduleTemplateService.TeamScheduleTemplateRequest

global abstract class TeamScheduleTemplateRequest

The request structure for the TeamScheduleTemplateRequest class.

Properties

Name Type Description
TeamId Id The team id associated with the team schedule template.
TemplateName String The template name.

pse.TeamScheduleTemplateService.CreateTeamScheduleTemplateRequest

global class CreateTeamScheduleTemplateRequest extends TeamScheduleTemplateRequest

The request structure for creating a team schedule template.

This class extends pse.TeamScheduleTemplateService.TeamScheduleTemplateRequest

Properties

Name Type Description
Slots List<pse.TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail> The list of TeamScheduleTemplateSlotDetail objects used to create schedule template slots for team schedule.

Methods

CreateTeamScheduleTemplateRequest

global CreateTeamScheduleTemplateRequest(Id teamId, String templateName, List<pse.TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail> slots)

A default constructor CreateTeamScheduleTemplateRequest class with the minimum required properties.

Input Parameters

Name Type Description
teamId Id The team id.
templateName String The template name.
slots List<pse.TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail> The list of TeamScheduleTemplateSlotDetail objects used to create time slots of a team schedule template.

pse.TeamScheduleTemplateService.TeamScheduleTemplateSlotDetail

global class TeamScheduleTemplateSlotDetail

The structure for the Custom Exception class, used to throw errors.

Properties

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

Methods

TeamScheduleTemplateSlotDetail

global TeamScheduleTemplateSlotDetail(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 schedule template time slot.
startTime string The start time of schedule template time slot.
endTime string The end time of schedule template time slot.
hours decimal The total hours of schedule template time slot.
capacity Integer The number of resources required for schedule template time slot.
slotTypeId Id The id of the schedule slot type for the schedule template time slot.
© Copyright 2009–2018 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.