pse.ResourceAssignmentServiceglobal with sharing class ResourceAssignmentService This class contains methods and structures to hold or assign resources against resource requests. EnumsSchedulingStrategy
Methods
holdResourceRequestsglobal static List<pse.ResourceAssignmentService.ResourceAssignmentResponse> holdResourceRequests(List<pse.ResourceAssignmentService.ResourceAssignmentRequest> resourceAssignRequests) This service enables you to hold the requested resource on a Resource Request. You must have the Resource Request Entry permission control assigned to hold resources. Input Parameters
Return ValueReturns the list of pse.ResourceAssignmentService.ResourceAssignmentResponse. 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: Holding a resource on a resource request with resource availability. *************************************************************************************************************************** /* pse__Resource_Request__c resReq = [SELECT Id, pse__Resource__c, pse__Start_Date__c FROM pse__Resource_Request__c WHERE Id = 'a1nDS000001j8fnYAA']; pse.ResourceAssignmentService.ResourceAssignmentRequest resAssignRequest = new pse.ResourceAssignmentService.ResourceAssignmentRequest(); resAssignRequest.ResourceRequestId = resReq.Id; resAssignRequest.ResourceId = resReq.pse__Resource__c; resAssignRequest.StartDate = resReq.pse__Start_Date__c; resAssignRequest.Strategy = pse.ResourceAssignmentService.SchedulingStrategy.CALCULATE_END_DATE_LEVEL_SCHEDULE; List<pse.ResourceAssignmentService.ResourceAssignmentRequest> requestList = new List<pse.ResourceAssignmentService.ResourceAssignmentRequest>{resAssignRequest}; List<pse.ResourceAssignmentService.ResourceAssignmentResponse> responseList = pse.ResourceAssignmentService.holdResourceRequests(requestList); /* *************************************************************************************************************************** Example 2: Holding a resource on a resource request with custom start date and level schedule strategy. *************************************************************************************************************************** /* pse__Resource_Request__c resReq = [SELECT Id, pse__Resource__c FROM pse__Resource_Request__c WHERE Id = 'a1nDS000001j8fnYAA']; pse.ResourceAssignmentService.ResourceAssignmentRequest resAssignRequest = new pse.ResourceAssignmentService.ResourceAssignmentRequest(); resAssignRequest.ResourceRequestId = resReq.Id; resAssignRequest.ResourceId = resReq.pse__Resource__c; resAssignRequest.StartDate = Date.newInstance(2023, 01, 29); resAssignRequest.Strategy = pse.ResourceAssignmentService.SchedulingStrategy.CALCULATE_END_DATE_LEVEL_SCHEDULE; List<pse.ResourceAssignmentService.ResourceAssignmentRequest> requestList = new List<pse.ResourceAssignmentService.ResourceAssignmentRequest>{resAssignRequest}; List<pse.ResourceAssignmentService.ResourceAssignmentResponse> responseList = pse.ResourceAssignmentService.holdResourceRequests(requestList); /* *************************************************************************************************************************** Example 3: Holding a resource on a resource request with custom hours on week days. *************************************************************************************************************************** /* Map<String, Decimal> customHours = new Map<String, Decimal>(); customHours.put('mon', 8); customHours.put('tue', 8); customHours.put('wed', 8); customHours.put('thu', 8); customHours.put('fri', 8); customHours.put('sat', 4); customHours.put('sun', 0); pse__Resource_Request__c resReq = [SELECT Id, pse__Resource__c FROM pse__Resource_Request__c WHERE Id = 'a1nDS000001j8fnYAA']; pse.ResourceAssignmentService.ResourceAssignmentRequest resAssignRequest = new pse.ResourceAssignmentService.ResourceAssignmentRequest(); resAssignRequest.ResourceRequestId = resReq.Id; resAssignRequest.ResourceId = resReq.pse__Resource__c; resAssignRequest.StartDate = Date.newInstance(2023, 01, 29); resAssignRequest.EndDate = Date.newInstance(2023, 02, 04); resAssignRequest.Strategy = pse.ResourceAssignmentService.SchedulingStrategy.CALCULATE_END_DATE_CUSTOM_SCHEDULING; resAssignRequest.CustomHours = customHours; List<pse.ResourceAssignmentService.ResourceAssignmentRequest> requestList = new List<pse.ResourceAssignmentService.ResourceAssignmentRequest>{resAssignRequest}; List<pse.ResourceAssignmentService.ResourceAssignmentResponse> responseList = pse.ResourceAssignmentService.holdResourceRequests(requestList); assignResourceRequestsglobal static List<pse.ResourceAssignmentService.ResourceAssignmentResponse> assignResourceRequests(List<pse.ResourceAssignmentService.ResourceAssignmentRequest> resourceAssignRequests) This services enables you to create Assignment with the requested resource on the Resource Request. You must have the Resource Request Entry and Staffing permission control assigned to create assignments. Input Parameters
Return ValueReturns the list of pse.ResourceAssignmentService.ResourceAssignmentResponse. 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: Create an Assignment from a Resource Request, respecting the resource's availability. *************************************************************************************************************************** /* pse__Resource_Request__c resReq = [SELECT Id, pse__Resource__c, pse__Start_Date__c FROM pse__Resource_Request__c WHERE Id = 'a1nDS000001j8fnYAA']; pse.ResourceAssignmentService.ResourceAssignmentRequest resAssignRequest = new pse.ResourceAssignmentService.ResourceAssignmentRequest(); resAssignRequest.ResourceRequestId = resReq.Id; resAssignRequest.ResourceId = resReq.pse__Resource__c; resAssignRequest.StartDate = resReq.pse__Start_Date__c; resAssignRequest.Strategy = pse.ResourceAssignmentService.SchedulingStrategy.CALCULATE_END_DATE_LEVEL_SCHEDULE; List<pse.ResourceAssignmentService.ResourceAssignmentRequest> requestList = new List<pse.ResourceAssignmentService.ResourceAssignmentRequest>{resAssignRequest}; List<pse.ResourceAssignmentService.ResourceAssignmentResponse> responseList = pse.ResourceAssignmentService.assignResourceRequests(requestList); /* *************************************************************************************************************************** Example 2: Create an Assignment from a Resource Request with custom start date and level schedule strategy. *************************************************************************************************************************** /* pse__Resource_Request__c resReq = [SELECT Id, pse__Resource__c FROM pse__Resource_Request__c WHERE Id = 'a1nDS000001j8fnYAA']; pse.ResourceAssignmentService.ResourceAssignmentRequest resAssignRequest = new pse.ResourceAssignmentService.ResourceAssignmentRequest(); resAssignRequest.ResourceRequestId = resReq.Id; resAssignRequest.ResourceId = resReq.pse__Resource__c; resAssignRequest.StartDate = Date.newInstance(2023, 01, 29); resAssignRequest.Strategy = pse.ResourceAssignmentService.SchedulingStrategy.CALCULATE_END_DATE_LEVEL_SCHEDULE; List<pse.ResourceAssignmentService.ResourceAssignmentRequest> requestList = new List<pse.ResourceAssignmentService.ResourceAssignmentRequest>{resAssignRequest}; List<pse.ResourceAssignmentService.ResourceAssignmentResponse> responseList = pse.ResourceAssignmentService.assignResourceRequests(requestList); /* *************************************************************************************************************************** Example 3: Create an Assignment from a Resource Request with custom hours on week days. *************************************************************************************************************************** /* Map<String, Decimal> customHours = new Map<String, Decimal>(); customHours.put('mon', 8); customHours.put('tue', 8); customHours.put('wed', 8); customHours.put('thu', 8); customHours.put('fri', 8); customHours.put('sat', 4); customHours.put('sun', 0); pse__Resource_Request__c resReq = [SELECT Id, pse__Resource__c FROM pse__Resource_Request__c WHERE Id = 'a1nDS000001j8fnYAA']; pse.ResourceAssignmentService.ResourceAssignmentRequest resAssignRequest = new pse.ResourceAssignmentService.ResourceAssignmentRequest(); resAssignRequest.ResourceRequestId = resReq.Id; resAssignRequest.ResourceId = resReq.pse__Resource__c; resAssignRequest.StartDate = Date.newInstance(2023, 01, 29); resAssignRequest.EndDate = Date.newInstance(2023, 02, 04); resAssignRequest.Strategy = pse.ResourceAssignmentService.SchedulingStrategy.CALCULATE_END_DATE_CUSTOM_SCHEDULING; resAssignRequest.CustomHours = customHours; List<pse.ResourceAssignmentService.ResourceAssignmentRequest> requestList = new List<pse.ResourceAssignmentService.ResourceAssignmentRequest>{resAssignRequest}; List<pse.ResourceAssignmentService.ResourceAssignmentResponse> responseList = pse.ResourceAssignmentService.assignResourceRequests(requestList); pse.ResourceAssignmentService.ResourceAssignmentRequestglobal with sharing class ResourceAssignmentRequest The request structure contains parameters for holding a resource on a Resource Request or assigning a Resource Request to a resource. The CustomHours and PercentAlloc fields are required for the CALCULATE_END_DATE_CUSTOM_SCHEDULING and PERCENT_ALLOCATION scheduling strategies, respectively. Properties
pse.ResourceAssignmentService.ResourceAssignmentResponseglobal with sharing class ResourceAssignmentResponse The response structure returns information related to the resource request ID and resource ID. Properties
|