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.

This class contains deprecated items.

Methods

addFromTemplates

global static List<pse.AddFromProjectTemplateService.AddFromProjectResponse> addFromTemplates(List<pse.AddFromProjectTemplateService.AddFromProjectRequest> requests)

This method clones related records 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.AddFromProjectRequest> The list of requests in AddFromProjectRequest.

Return Value

This service returns values in the AddFromProjectResponses list in response to the requests in 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 = 'a2V0R000001km2BUAQ';
Id template2 = 'a2V0R000001khHXUAY';
Id destination = 'a2V0R000001km2LUAQ';

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

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

// Enqueue the Add From Template requests
List<pse.AddFromProjectTemplateService.AddFromProjectResponse> responses = 
    pse.AddFromProjectTemplateService.addFromTemplates(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);
    }
}

Deprecated

The following items are deprecated and not supported for use. We recommend that you stop using these items to avoid exceptions.

Methods

addTasksFromTemplates

Deprecated: Use addFromTemplates(List requests) instead.

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 field sets. Mappers can be used to select specific related records to copy. See SObjectCloneMapper.
StartDate Date the date after which to insert the related objects.
If the Work_Calendar__c field on the Project_Task__c sObject has been included in either Project Task field set or passed as a Mapper on this request, project tasks are adjusted into working time after the offset is applied. This determines the 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 addfromtemplates.
Tasks are scheduled so that the earliest task will start on StartDate. If EndDate is set, tasks are scheduled so that the latest ending task will end on EndDate. 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.
Fields are copied from a project task field set that is referenced in the following custom settings:
• Template Proj Task Fieldset
• Template Proj Alt Copy Task Fieldset

This class extends pse.AddFromProjectTemplateService.AddFromProjectRequest

Properties

Name Type Description
CopyMilestones Boolean copies milestones that are associated with project tasks, which are not copied by default.
Fields are copied from a Milestone field set that is referenced in the following custom settings:
• Template Proj MS Fieldset
• Template Proj Alt Copy MS Fieldset
CopyProjectTaskAssignments Boolean copy project task assignments (ptas), they are not copied by default.
Fields are copied from a project task assignment field set that is referenced in the following custom settings:
• Template Proj Copy PTA Fieldset
EndDate Date the last date that the copied related objects should end on. If this field is set, StartDate must be null.
If the Work_Calendar__c field on the Project_Task__c sObject has been included in either of the Project Task field sets or passed as a Mapper on this request, project tasks are adjusted into working time after the offset is applied. This determines the working days according to the Work_Calendar__c on each project task.

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

global with sharing class MilestoneRequest extends AddFromProjectRequest

the request structure for adding milestones from template only. to be used with addmilestonesfromtemplates.
Fields are copied from a Milestone field set that is referenced in the following custom settings:
• Template Proj MS Fieldset
• Template Proj Columns MS Fieldset
• Template Proj Alt Copy MS Fieldset

This class extends pse.AddFromProjectTemplateService.AddFromProjectRequest

Properties

Name Type Description
CopyRisks Boolean copies risks, which are are not copied by default.
Fields are copied from a Risk field set that is referenced in the following custom settings:
• Template Proj Risk Fieldset
• Template Proj Alt Copy Risk Fieldset

Methods

MilestoneRequest

global MilestoneRequest(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.ResourceRequestToProjectRequest

global with sharing class ResourceRequestToProjectRequest extends AddFromProjectRequest

the request structure for adding resource requests to a project. to be used with addfromtemplates.
Fields are copied from a Resource Request field set that is referenced in the following custom settings:
• Template Proj RR Fieldset
• Template Proj Columns RR Fieldset
• Template Proj Alt Copy RR Fieldset

This class extends pse.AddFromProjectTemplateService.AddFromProjectRequest

Properties

Name Type Description
CopyResourceSkillRequests Boolean copies resource skill requests, which are are not copied by default.
Fields are copied from a Resource Skill Request field set that is referenced in the Resource Skill Request Fieldset custom setting.

Methods

ResourceRequestToProjectRequest

global ResourceRequestToProjectRequest(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–2021 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.