PSA Apex API Developer Reference

pse.AddFromProjectTemplateService

global with sharing class AddFromProjectTemplateService

A service used to clone related records between projects. Core fields of copied objects are also copied.

Methods

addTasksFromTemplates

global static List<pse.AddFromProjectTemplateService.AddFromProjectResponse> addTasksFromTemplates(List<pse.AddFromProjectTemplateService.ProjectTaskRequest> requests)

This method clones project tasks between projects using the details specified. Multiple requests are executed asynchronously and sequentially, in the given order.

Input Parameters

Name Type Description
requests List<pse.AddFromProjectTemplateService.ProjectTaskRequest> The list of ProjectTaskRequest.

Return Value

This service returns AddFromProjectResponses in a list that parallels the input list.

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.

Id template1 = 'a2V2F000000xpS3UAI';
Id template2 = 'a2V2F000000xpS4UAI';
Id destination = 'a2V2F000000xpSGUAY';
Date startDate = Date.Today();

pse.AddFromProjectTemplateService.ProjectTaskRequest request1 = 
    new pse.AddFromProjectTemplateService.ProjectTaskRequest(template1, destination);
pse.AddFromProjectTemplateService.ProjectTaskRequest request2 = 
    new pse.AddFromProjectTemplateService.ProjectTaskRequest(template2, destination);

request1.StartDate = startDate;
request2.StartDate = startDate;

List<pse.AddFromProjectTemplateService.ProjectTaskRequest> requests = 
    new List<pse.AddFromProjectTemplateService.ProjectTaskRequest>{ request1, request2 };

// Enqueue the Add Tasks From Template requests
List<pse.AddFromProjectTemplateService.AddFromProjectResponse> responses = 
    pse.AddFromProjectTemplateService.addTasksFromTemplates(requests);

// Loop through each response to see whether the request succeeded or failed
for (pse.AddFromProjectTemplateService.AddFromProjectResponse response : responses) {
    if (response.isSuccess()) {
        System.debug('Successfully queued this request: ' + response.Request);
    } else {
        System.debug('This request failed: ' + response.Request);
        System.debug('Reasons: ' + response.Errors);
    }
}

pse.AddFromProjectTemplateService.AddFromProjectRequest

global abstract class AddFromProjectRequest

The request structure for the AddFromProjectTemplateService.

Properties

Name Type Description
DestinationProjectId Id The project ID that related records are copied to.
Mappers List<pse.SObjectCloneMapper> The SObjectCloneMapper list defining which fields are copied for which SObjects when adding related records from a template. This is in addition to the default objects and fields as well as the fields contained in the 'CreateProjFromTemp' field sets. Mappers can be used to select specific related records to copy. See SObjectCloneMapper.
StartDate Date The date to insert the related objects.
If the Work_Calendar__c field on Project_Task__c sObject has been included in either Project Task field set or passed as a Mapper on this request then Project Tasks will be adjusted into working time after the offset has applied. This will determine which days are working days according to the Work_Calendar__c on each Project Task.
TemplateProjectId Id The template project ID that related records are copied from.

pse.AddFromProjectTemplateService.ProjectTaskRequest

global with sharing class ProjectTaskRequest extends AddFromProjectRequest

The request structure for adding tasks from template only. To be used with addTasksFromTemplates.
Tasks are scheduled so that the earliest task will start on StartDate. Tasks are appended to the bottom of the hierarchy of the destination project. The WBS of the copied tasks is cleared, it can be regenerated by opening the project in Gantt.

This class extends pse.AddFromProjectTemplateService.AddFromProjectRequest

Properties

Name Type Description
CopyProjectTaskAssignments Boolean Copy project task assignments (PTAs), they are not copied by default.

Methods

ProjectTaskRequest

global ProjectTaskRequest(Id templateProjectId, Id destinationProjectId)

A default constructor with minimum required properties.

Input Parameters

Name Type Description
templateProjectId Id The project template ID.
destinationProjectId Id The destination project ID.

pse.AddFromProjectTemplateService.AddFromProjectResponse

global class AddFromProjectResponse

The response structure returned for each request.

Properties

Name Type Description
Request pse.AddFromProjectTemplateService.AddFromProjectRequest The request associated with the response of AddFromProjectTemplateService.
Errors List<pse.AddFromProjectTemplateService.AddFromProjectError> Stores error messages that occur when executing methods from AddFromProjectTemplateService.
QueuedJobId Id The AddFromProjectTemplateService creates Queueables to complete the work in later transactions. This is the ID of the AsyncApexJob controlling the work. The record can be queried to monitor its status. When multiple requests are processed, only the QueuedJobId of the first response is set.

Methods

isSuccess

global Boolean isSuccess()

Indicates if the request was queued successfully.

pse.AddFromProjectTemplateService.AddFromProjectError

global with sharing class AddFromProjectError

Stores error messages that occur when executing methods from AddFromProjectTemplateService.

Properties

Name Type Description
Message String The error message.
© Copyright 2009–2020 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.