Professional Services Automation Apex API Developer Reference

pse.ServicesDeliverableService

global with sharing class ServicesDeliverableService

This class contains methods to push services credits deliverables and their related records to projects for delivery.

Enums

AllocationMode

Value Description
ALLOCATION_REQUIRE_SUCCESS This mode requires that services credits allocation is successful in order for adding the deliverables to succeed. This mode means that an allocation of credits is attempted after the project deliverable items and milestones have been created. It also requires success of the entire request for any records to be created. This means that if any of the deliverables are not found, or invalid, any milestones fail to insert, or the allocation of deliverables credits fails then none of the deliverables in the request will be added to the target project.
ALLOCATION_ALLOW_FAILURE This mode means that we attempt to allocate credits in addition to pushing deliverables to the target project. In the case of individual deliverables or the allocation failing, all of the other data requested is still created.
NO_ALLOCATION This mode does not attempt to allocate services credits when adding the deliverables.

Methods

addDeliverablesToProject

global static pse.ServicesDeliverableService.AddServicesDeliverableResponse addDeliverablesToProject(pse.ServicesDeliverableService.AddServicesDeliverableRequest request)

A method which uses services deliverables as templates to push project deliverables to projects. For each deliverable specified a project deliverable will be created, as well as a project deliverable item for each active linked deliverable item. The milestones linked to the deliverable items will be duplicated on the target project, along with any linked Tasks, Project Task Dependencies, Project Task Assignments, Resource Requests, Resource Skill Requests, Schedules, Schedule Exceptions, and Risks. The date fields on these records will be shifted to account for the difference in start date between the source and target project.

Input Parameters

Name Type Description
request pse.ServicesDeliverableService.AddServicesDeliverableRequest Contains the request to add services deliverables to a project.

Exceptions Thrown

Value Description
PSAException Thrown when the request or any of the requests members is null or empty.
fflib_SecurityUtils.FlsException Thrown when the running user does not have read/write rights to any fields on any of the objects involved.
fflib_SecurityUtils.CrudException Thrown when the running user does not have read/write rights to any of the objects involved.

Return Value

AddServicesDeliverableResponse Contains the response to adding services deliverables.

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.

//construct the request object
List<Id> deliverableIds = new List<Id>{
    'a1r000000000001AAA',
    'a1r000000000002AAA',
    'a1r000000000003AAA'
};
pse.ServicesDeliverableService.AddServicesDeliverableRequest request = new pse.ServicesDeliverableService.AddServicesDeliverableRequest();
request.deliverableIds = deliverableIds;
request.projectId = 'a0r000000000001AAA';
request.allocationMode = pse.ServicesDeliverableService.AllocationMode.ALLOCATION_ALLOW_FAILURE;

//call the service
pse.ServicesDeliverableService.AddServicesDeliverableResponse response = pse.ServicesDeliverableService.addDeliverablesToProject(
    request
);

//response if successful
pse.ServicesDeliverableService.AddDeliverableResult firstResult = response.results[0];
pse__Services_Deliverable_Instance__c firstDeliverableInstance = firstResult.deliverableInstance; // this will be populated
List<String> firstDeliverableErrorMessages = firstResult.errorMessages; // this will be empty

//response if there was an error
pse.ServicesDeliverableService.AddDeliverableResult secondResult = response.results[1];
pse__Services_Deliverable_Instance__c secondDeliverableInstance = secondResult.deliverableInstance; // this would be null
List<String> secondDeliverableErrorMessages = secondResult.errorMessages; // this will be populated

pse.ServicesDeliverableService.AddServicesDeliverableRequest

global with sharing class AddServicesDeliverableRequest

Contains the request to add a services deliverable to a project.

Properties

Name Type Description
projectId Id The ID of the project to which the deliverable is added to.
deliverableIds List<Id> The list of IDs of the deliverables to add.
allocationMode pse.ServicesDeliverableService.AllocationMode The type of mode by which services credits allocation is executed when adding the deliverables.

Methods

AddServicesDeliverableRequest

global AddServicesDeliverableRequest()

pse.ServicesDeliverableService.AddServicesDeliverableResponse

global with sharing class AddServicesDeliverableResponse

Contains the response to adding services deliverables.

Properties

Name Type Description
results List<pse.ServicesDeliverableService.AddDeliverableResult> A list of results of the process for each individual deliverable ID included in the request.

Methods

AddServicesDeliverableResponse

global AddServicesDeliverableResponse()

pse.ServicesDeliverableService.AddDeliverableResult

global with sharing class AddDeliverableResult

The result of an individual services deliverable in the add deliverables to project process.

Properties

Name Type Description
deliverableId Id The deliverable ID the result relates to.
errorMessages List<String> If there were errors, this will contain error messages. In the case of ALLOCATION_ALLOW_FAILURE mode, this list may contain errors related to the allocation even if the project deliverable itself has been successfully created.
deliverableInstance pse__Services_Deliverable_Instance__c If pushing the deliverable to the project was successful then this field will contain the created project services deliverable record, which will be linked to all of the created records. If pushing the deliverable failed, then this field will not be populated.

Methods

AddDeliverableResult

global AddDeliverableResult()

© Copyright 2009–2025 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.