Professional Services Automation Apex API Developer Reference

pse.ServicesDeliverableService

global with sharing class ServicesDeliverableService

This class contains methods to push services 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 with services credits pricing 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
pselib_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

addMonetaryPricedDeliverablesToProject

global static pse.ServicesDeliverableService.AddMonetaryPricedDeliverableResponse addMonetaryPricedDeliverablesToProject(pse.ServicesDeliverableService.AddMonetaryPricedDeliverableRequest pricedDeliverableRequest)

A method which uses services deliverables as templates to push project deliverables with monetary pricing 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
pricedDeliverableRequest pse.ServicesDeliverableService.AddMonetaryPricedDeliverableRequest Contains the request to add services deliverables to a project.

Exceptions Thrown

Value Description
pselib_PSAException Thrown when the request is null, the project ID or the inputs within the request are null, or if any of the deliverable inputs are missing a deliverable ID or price.
fflib_SecurityUtils.FlsException Thrown when the running user lacks read permissions, write permissions, or both, for any fields on any of the objects involved.
fflib_SecurityUtils.CrudException Thrown when the running user lacks read permissions, write permissions, or both, for any of the objects involved.

Return Value

AddMonetaryPricedDeliverableResponse 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.

//Create a list of inputs. Each input contains the ID of the deliverable to add and its corresponding price.
List<pse.ServicesDeliverableService.MonetaryPricedDeliverableInput> pricedDeliverables = new List<pse.ServicesDeliverableService.MonetaryPricedDeliverableInput>{
    new pse.ServicesDeliverableService.MonetaryPricedDeliverableInput(
        'a1r000000000001AAA',
        42000.50
    ),
    new pse.ServicesDeliverableService.MonetaryPricedDeliverableInput('a1r000000000002AAA', 6000),
    new pse.ServicesDeliverableService.MonetaryPricedDeliverableInput(
        'a1r000000000003AAA',
        10450.45
    )
};

Id destinationProjectId = 'a1r000000000001AAB';

//Create the request
pse.ServicesDeliverableService.AddMonetaryPricedDeliverableRequest request = new pse.ServicesDeliverableService.AddMonetaryPricedDeliverableRequest();
request.projectId = destinationProjectId;
request.monetaryPricedDeliverables = pricedDeliverables;

//Call the service
pse.ServicesDeliverableService.AddMonetaryPricedDeliverableResponse response = pse.ServicesDeliverableService
    .addMonetaryPricedDeliverablesToProject(request);

//Response if the addition is successful
pse.ServicesDeliverableService.AddMonetaryPricedDeliverableResult 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 are errors during the addition
pse.ServicesDeliverableService.AddMonetaryPricedDeliverableResult secondResult = response.results[1];
pse__Services_Deliverable_Instance__c secondDeliverableInstance = secondResult.deliverableInstance; // This will be null
List<String> secondDeliverableErrorMessages = secondResult.errorMessages; // This will contain error messages indicating why this deliverable failed to be added

pse.ServicesDeliverableService.AddServicesDeliverableRequest

global with sharing class AddServicesDeliverableRequest

Contains the request to add services deliverables with services credits pricing to a project.

Properties

Name Type Description
projectId Id The ID of the project the deliverables are 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 with services credits pricing.

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 process of adding deliverables with services credits pricing to a project.

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()

hasErrors

global Boolean hasErrors()

Returns true if there were errors when attempting the addition.

pse.ServicesDeliverableService.MonetaryPricedDeliverableInput

global with sharing class MonetaryPricedDeliverableInput

This class represents a services deliverable to be added to a project, along with its monetary price.

Properties

Name Type Description
deliverableId Id The ID of the deliverable to be added to the project.
price Decimal The price of the deliverable to be added to the project, in the project's currency.

Methods

MonetaryPricedDeliverableInput

global MonetaryPricedDeliverableInput(Id deliverableId, Decimal price)

pse.ServicesDeliverableService.AddMonetaryPricedDeliverableRequest

global with sharing class AddMonetaryPricedDeliverableRequest

Contains the request to add services deliverables with monetary pricing to a project.

Properties

Name Type Description
projectId Id The ID of the project the deliverables are added to.
monetaryPricedDeliverables List<pse.ServicesDeliverableService.MonetaryPricedDeliverableInput> The list of deliverables to add, along with their monetary prices.

Methods

AddMonetaryPricedDeliverableRequest

global AddMonetaryPricedDeliverableRequest()

pse.ServicesDeliverableService.AddMonetaryPricedDeliverableResponse

global with sharing class AddMonetaryPricedDeliverableResponse

Contains the response to adding services deliverables with monetary pricing.

Properties

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

Methods

AddMonetaryPricedDeliverableResponse

global AddMonetaryPricedDeliverableResponse(List<pse.ServicesDeliverableService.AddMonetaryPricedDeliverableResult> results)

pse.ServicesDeliverableService.AddMonetaryPricedDeliverableResult

global with sharing class AddMonetaryPricedDeliverableResult

The result of an individual services deliverable in the process of adding deliverables with monetary pricing to a project.

Properties

Name Type Description
deliverableId Id The deliverable ID the result relates to.
errorMessages List<String> The list of error messages if the addition fails.
deliverableInstance pse__Services_Deliverable_Instance__c If the addition is successful, this field contains the created project services deliverable record, which will be linked to all of the created records. If the addition fails, this field is not populated.

Methods

hasErrors

global Boolean hasErrors()

Returns true if there were errors when attempting the addition.

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