PSA Apex API Developer Reference

pse.VersionService

global with sharing class VersionService

Service to create a version of a project and its details.

Methods

createAsync

global static List<Id> createAsync(List<pse.VersionService.Version> versions)

Creates versions of projects using the version instances provided. The call creates the Version records synchronously. Then one asynchronous batch process starts for each version in the request and copies the child records for that version.

Input Parameters

Name Type Description
versions List<pse.VersionService.Version> List of configurations for creating new versions. Any versionID supplied in the configuration is ignored.

Return Value

This service returns the newly created version IDs.

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 projectId = Id.valueOf('a1Q1a0000006VJ4');// A valid pse__Proj__c record Id to take Version of.

//Version setup.
pse.VersionService.Version dto = new pse.VersionService.Version();
dto.ProjectId = projectId;
dto.VersionName = 'Demo Version name';
dto.Notes = 'Demo notes.';
dto.Baseline = true;

List<pse.VersionService.Version> versions = new List<pse.VersionService.Version> { dto };

//Call API
List<Id> versionIds = pse.VersionService.createAsync(versions);

deleteAsync

global static void deleteAsync(List<Id> versionIds)

Removes project versions and all project version child records. This method runs asynchronously, running batch processes to delete project version data. Project version statuses immediately update to Deleting and the records should not be subsequently used.

Input Parameters

Name Type Description
versionIds List<Id> The Id of the records to be deleted.

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 projectId = Id.valueOf('a1Q1a0000006VJ4');// A valid pse__Proj__c record Id we are working with.

//Find the oldest non-baseline version of this project.
List<pse__Version__c> versions = [SELECT Id FROM pse__Version__c WHERE pse__Baseline__c = false AND pse__Project__c =: projectId ORDER BY CreatedDate LIMIT 1];
Id oldestVersionId = versions[0].Id;

List<Id> versionIdsToDelete = new List<Id> { oldestVersionId };

//Call API
List<Id> versionIds = pse.VersionService.deleteAsync(versionIdsToDelete);

pse.VersionService.Version

global class Version

This class is used to define how a project version can be created.

Properties

Name Type Description
ProjectId Id ID of the pse__proj__c record the version belongs to.
VersionName String Name of the version.
Notes String Notes to associate with the version.
Baseline Boolean Set the version as a baseline.
© Copyright 2009–2018 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.