Professional Services Automation Apex API Developer Reference

pse.ResourceAssignmentService

global with sharing class ResourceAssignmentService

This class contains methods and structures to hold or assign resources against resource requests.

Enums

SchedulingStrategy

Value Description
CALCULATE_END_DATE_LEVEL_SCHEDULE calculates end date respecting availability
CALCULATE_END_DATE_IGNORE_AVAILABILITY calculates end date ignoring availability.
ADJUST_DAILY_HOURS adjusts per day hours based on start date, end date, and total hours.
CALCULATE_END_DATE_CUSTOM_SCHEDULING use pattern to set hours on each day of week.
PERCENT_ALLOCATION allocates hours based on percentage.
ZERO_HOUR_SCHEDULING creates schedule with zero hours for each day.

Methods

holdResourceRequests

global 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

Name Type Description
resourceAssignRequests List<pse.ResourceAssignmentService.ResourceAssignmentRequest> List of ResourceAssignmentRequest.

Return Value

Returns 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);

assignResourceRequests

global 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

Name Type Description
resourceAssignRequests List<pse.ResourceAssignmentService.ResourceAssignmentRequest> List of ResourceAssignmentRequest.

Return Value

Returns 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.ResourceAssignmentRequest

global 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

Name Type Description
ResourceRequestId Id Resource Request ID for holding or creating assignments for a resource.
ResourceId Id Resource ID for holding resource requests or assigning on assignments.
StartDate Date Start date for the schedule.
EndDate Date End date for the schedule.
Strategy pse.ResourceAssignmentService.SchedulingStrategy Strategy for schedule calculation. Additional properties may be required depending on the chosen strategy.
CustomHours Map<String, Decimal> Hours for each day when custom scheduling strategy is selected.
PercentAlloc Decimal Percentage to create a schedule when the percent allocation scheduling strategy is selected.

pse.ResourceAssignmentService.ResourceAssignmentResponse

global with sharing class ResourceAssignmentResponse

The response structure returns information related to the resource request ID and resource ID.

Properties

Name Type Description
ResourceRequestId Id Resource Request ID for holding or creating assignments for a resource.
Resource Id Resource ID for holding resource requests or assigning on assignments.
© Copyright 2009–2024 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.