pse.ScheduleResourceServiceglobal with sharing class ScheduleResourceService Contains methods and structures to retrieve weekly scheduled hours information for schedules. MethodsgetScheduledHoursForWeeksglobal static pse.ScheduleResourceService.ScheduleResourceServiceResponse getScheduledHoursForWeeks(pse.ScheduleResourceService.ScheduleResourceServiceRequest scheduleResourceServiceRequest) Enables you to retrieve weekly scheduled hours information for schedules. Input Parameters
Return ValueReturns ScheduleResourceService.ScheduleResourceServiceResponse. 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. /* *************************************************************************************************************************** Example 1: Displays an error details response when an invalid End Date (i.e End Date earlier than Start Date) is sent to the scheduleHoursForWeeks method. *************************************************************************************************************************** /* Date currentDate = Date.today(); Id scheduleID = 'a1vHo0000022jT4IAI'; pse.ScheduleResourceService.ScheduleResourceServiceRequest request = new pse.ScheduleResourceService.ScheduleResourceServiceRequest(); request.ScheduleIds = new Set<Id>{ scheduleID }; request.WeekStartDay = pse.CalendarUtil.DayOfWeek.TUESDAY; request.StartDate = currentDate; request.EndDate = currentDate.addDays(-10); pse.ScheduleResourceService.ScheduleResourceServiceResponse response = pse.ScheduleResourceService.getScheduledHoursForWeeks(request); List<pse.ScheduleResourceService.ScheduleWeeklyData> scheduleWeeklyData = response.WeeklySchedules; Set<Id> remainingScheduleIds = response.RemainingScheduleIds; List<pse.ScheduleResourceService.ErrorDetail> errorDetails = response.ErrorDetails; System.debug('RemainingScheduleIds: ' + remainingScheduleIds); System.debug('Schedule Weekly Data: ' + scheduleWeeklyData); System.debug('Error Details: ' + errorDetails); /* *************************************************************************************************************************** Example 2: Displays error details response when an invalid scheduleID is sent to the scheduleHoursForWeeks method. *************************************************************************************************************************** /* Date startDateOfValidScheduleID = Date.newInstance(2022, 08, 08);\ // Id of schedule which has schedule hours available for startDateOfValidScheduleID Id validScheduleID = 'a1vHo0000022jT4IAI'; Id invalidScheduleID = 'a23530000018xkoAXB'; pse.ScheduleResourceService.ScheduleResourceServiceRequest request = new pse.ScheduleResourceService.ScheduleResourceServiceRequest(); request.ScheduleIds = new Set<Id>{ validScheduleID, invalidScheduleID }; request.WeekStartDay = pse.CalendarUtil.DayOfWeek.TUESDAY; request.StartDate = startDateOfValidScheduleID.addDays(5); request.EndDate = startDateOfValidScheduleID.addDays(10); pse.ScheduleResourceService.ScheduleResourceServiceResponse response = pse.ScheduleResourceService.getScheduledHoursForWeeks(request); List<pse.ScheduleResourceService.ScheduleWeeklyData> scheduleWeeklyData = response.WeeklySchedules; Set<Id> remainingScheduleIds = response.RemainingScheduleIds; List<pse.ScheduleResourceService.ErrorDetail> errorDetails = response.ErrorDetails; System.debug('RemainingScheduleIds: ' + remainingScheduleIds); System.debug('Schedule Weekly Data: ' + scheduleWeeklyData); System.debug('Error Details: ' + errorDetails); /* *************************************************************************************************************************** Example 3: Displays error details when an invalid date range is sent to the scheduleHoursForWeeks method. *************************************************************************************************************************** /* Date startDateOfValidScheduleID = Date.newInstance(2022, 08, 08); // Id of schedule which has schedule hours available for startDateOfValidScheduleID Id validScheduleID = 'a1vHo0000022jT4IAI'; pse.ScheduleResourceService.ScheduleResourceServiceRequest request = new pse.ScheduleResourceService.ScheduleResourceServiceRequest(); request.ScheduleIds = new Set<Id>{ validScheduleID }; request.WeekStartDay = pse.CalendarUtil.DayOfWeek.TUESDAY; request.StartDate = startDateOfValidScheduleID.addDays(-50); request.EndDate = startDateOfValidScheduleID.addDays(-10); request.BatchSize = 5 ; request.TransactionTimeLimit = 5000; pse.ScheduleResourceService.ScheduleResourceServiceResponse response = pse.ScheduleResourceService.getScheduledHoursForWeeks(request); List<pse.ScheduleResourceService.ScheduleWeeklyData> scheduleWeeklyData = response.WeeklySchedules; Set<Id> remainingScheduleIds = response.RemainingScheduleIds; List<pse.ScheduleResourceService.ErrorDetail> errorDetails = response.ErrorDetails; System.debug('RemainingScheduleIds: ' + remainingScheduleIds); System.debug('Schedule Weekly Data: ' + scheduleWeeklyData); System.debug('Error Details: ' + errorDetails); /* *************************************************************************************************************************** Example 4: Sends a valid response when a valid request is sent to the scheduleHoursForWeeks method. *************************************************************************************************************************** /* Date startDate = Date.newInstance(2023, 06, 06); // Ids of schedules which has schedule hours available for startDate Set<Id> validScheduleIDs = new Set<Id>{ 'a1vHo0000022jT4IAI', 'a1vHo0000022jT5IAI', 'a1vHo0000022jT8IAI' }; pse.ScheduleResourceService.ScheduleResourceServiceRequest request = new pse.ScheduleResourceService.ScheduleResourceServiceRequest(); request.ScheduleIds = validScheduleIDs; request.WeekStartDay = pse.CalendarUtil.DayOfWeek.TUESDAY; request.StartDate = startDate; request.EndDate = startDate.addDays(10); request.BatchSize = 2 ; request.TransactionTimeLimit = 5000; pse.ScheduleResourceService.ScheduleResourceServiceResponse response = pse.ScheduleResourceService.getScheduledHoursForWeeks(request); List<pse.ScheduleResourceService.ScheduleWeeklyData> scheduleWeeklyData = response.WeeklySchedules; Set<Id> remainingScheduleIds = response.RemainingScheduleIds; List<pse.ScheduleResourceService.ErrorDetail> errorDetails = response.ErrorDetails; System.debug('RemainingScheduleIds: ' + remainingScheduleIds); System.debug('Schedule Weekly Data Size: ' + scheduleWeeklyData.size()); System.debug('Schedule Weekly Data for schedule ID - ' + scheduleWeeklyData[0].ScheduleId + ': ' + scheduleWeeklyData[0]); System.debug('Schedule Weekly Data for schedule ID - ' + scheduleWeeklyData[1].ScheduleId + ': ' + scheduleWeeklyData[1]); System.debug('Error Details: ' + errorDetails); pse.ScheduleResourceService.ScheduleResourceServiceRequestglobal inherited sharing class ScheduleResourceServiceRequest Contains parameters for retrieving weekly scheduled hours information for schedules. Properties
MethodsScheduleResourceServiceRequestglobal ScheduleResourceServiceRequest() pse.ScheduleResourceService.WeeklyScheduleHoursglobal inherited sharing class WeeklyScheduleHours Contains information related to the week's start date and scheduled hours associated with it. Properties
MethodsWeeklyScheduleHoursglobal WeeklyScheduleHours() pse.ScheduleResourceService.ScheduleWeeklyDataglobal inherited sharing class ScheduleWeeklyData Contains information related to the schedule and weekly scheduled hours associated with it. Properties
MethodsScheduleWeeklyDataglobal ScheduleWeeklyData() pse.ScheduleResourceService.ErrorDetailglobal inherited sharing class ErrorDetail Contains information about any errors in the process. Properties
MethodsErrorDetailglobal ErrorDetail() pse.ScheduleResourceService.ScheduleResourceServiceResponseglobal inherited sharing class ScheduleResourceServiceResponse Returns information related to weekly scheduled hours for schedules. Properties
MethodsScheduleResourceServiceResponseglobal ScheduleResourceServiceResponse() |