PSA Apex API Developer Reference

pse.VersionConfigService

global class VersionConfigService

Methods

getActiveVersionConfig

global static pse__Version_Config__c getActiveVersionConfig()

This method returns the active Version_Config__c object, or the standard Version_Config__c object if there is not an active custom config.

Return Value

The active Version_Config__c record.

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.

pse__Version_Config__c activeConfig = pse.VersionConfigService.getActiveVersionConfig();

saveCaptureConfig

global static pse.VersionConfigService.VersionCaptureConfig saveCaptureConfig(Id configId, pse.VersionConfigService.VersionCaptureConfig toSave)

This method saves the given VersionCaptureConfig to the Version_Config__c object with the given ID.

Input Parameters

Name Type Description
configId Id ID of Version_Config__c objects to be saved.
toSave pse.VersionConfigService.VersionCaptureConfig VersionCaptureConfig object to be saved to the Version_Config__c.

Return Value

The saved VersionConfigService.VersionCaptureConfig.

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 configId = Id.valueOf('a3j1a0000008uAK'); // A valid pse__Version_Config__c record

pse.VersionConfigService.VersionCaptureConfig captureConfig = new pse.VersionConfigService.VersionCaptureConfig();

// configure to capture the Project object
pse.VersionConfigService.VersionCaptureObject projectConfig = new pse.VersionConfigService.VersionCaptureObject();
projectConfig.originatorAPIName = 'pse__Proj__c';
projectConfig.originatorProjectLookupFieldAPIName = '';
projectConfig.destinationAPIName = 'pse__VersionItem_ProjectDetail__c';
projectConfig.destinationVersionLookupFieldAPIName = 'pse__Version__c';
projectConfig.originalIdField = 'pse__OriginalId__c';

captureConfig.VersionedObjects.add(projectConfig);

// add the Project Task object to the capture configuration
pse.VersionConfigService.VersionCaptureObject taskConfig = new pse.VersionConfigService.VersionCaptureObject();
taskConfig.originatorAPIName = 'pse__Project_Task__c';
taskConfig.originatorProjectLookupFieldAPIName = 'pse__Project__c';
taskConfig.destinationAPIName = 'pse__VersionItem_Task__c';
taskConfig.destinationVersionLookupFieldAPIName = 'pse__Version__c';
taskConfig.originalIdField = 'pse__OriginalId__c';

captureConfig.VersionedObjects.add(taskConfig);

// add a custom object to the configuration
pse.VersionConfigService.VersionCaptureObject myObjectConfig = new pse.VersionConfigService.VersionCaptureObject();
// orgNs is the namespace of the org, if appropriate
myObjectConfig.originatorAPIName = 'orgNs__MyObject__c';
// custom objects have to have a lookup to Project to be versionable
myObjectConfig.originatorProjectLookupFieldAPIName = 'orgNs__Prj__c';
// the destination object for custom objects will need to be created by an administrator
myObjectConfig.destinationAPIName = 'orgNs__My_Destination_Object__c';
// and will need to have a lookup to the pse__Version__c object
myObjectConfig.destinationVersionLookupFieldAPIName = 'orgNs__Vrsn__c';
// and have a field for capturing the Id of the originator object
myObjectConfig.originalIdField = 'orgNs__My_Object_Id__c';

captureConfig.VersionedObjects.add(myObjectConfig);

captureConfig = pse.VersionConfigService.saveCaptureConfig(configId, captureConfig);

saveVersionConfigDetails

global static pse.VersionConfigService.VersionConfigDetails[] saveVersionConfigDetails(List<pse.VersionConfigService.VersionConfigDetails> details)

This method saves the given list of VersionConfigDetails to their equivalent Version_Config__c objects.

Input Parameters

Name Type Description
details List<pse.VersionConfigService.VersionConfigDetails> List of VersionConfigDetails to be saved.

Return Value

Updated VersionConfigService.VersionConfigDetails records.

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.

// return all the capture configuration sets on the org, we assume here that we get three back
pse.VersionConfigService.VersionConfigDetails[] details = pse.VersionConfigService.getAllVersionConfigDetails();

Integer i = 1;

for (pse.VersionConfigService.VersionConfigDetails detail : details)
{
    detail.Name = detail.Name + i;

    if (i == 3)
        detail.isDefault = true;

    i++;
}

// save all the capture configurations back to the org
pse.VersionConfigService.VersionConfigDetails[] updated = pse.VersionConfigService.saveVersionConfigDetails(details);

deleteVersionConfigDetails

global static void deleteVersionConfigDetails(List<Id> configIds)

This method deletes the Version_Config__c objects associated with the given list of IDs.

Input Parameters

Name Type Description
configIds List<Id> List of IDs 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.

// return all the capture configuration sets on the org, we assume here that we get five back
pse.VersionConfigService.VersionConfigDetails[] details = pse.VersionConfigService.getAllVersionConfigDetails();

List<Id> configsToDelete = new List<Id>();
configsToDelete.add(details[1].ConfigId);
configsToDelete.add(details[3].ConfigId);

pse.VersionConfigService.deleteVersionConfigDetails(configsToDelete);

getAllVersionConfigDetails

global static pse.VersionConfigService.VersionConfigDetails[] getAllVersionConfigDetails()

This method loads the ID, Unique_Name__c, Default__c, Summary__c and LastModifiedDate fields on all Version_Config__c objects

Return Value

List of Version_Config__c records.

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.

// return all the capture configuration sets on the org, we assume here that we get three back
pse.VersionConfigService.VersionConfigDetails[] details = pse.VersionConfigService.getAllVersionConfigDetails();

Integer i = 1;

for (pse.VersionConfigService.VersionConfigDetails detail : details)
{
    detail.Name = detail.Name + i;

    if (i == 3)
        detail.isDefault = true;

    i++;
}

// save all the capture configurations back to the org
pse.VersionConfigService.VersionConfigDetails[] updated = pse.VersionConfigService.saveVersionConfigDetails(details);

getConfigById

global static pse__Version_Config__c getConfigById(Id configId)

This method returns the Version_Config__c object with the ID as passed in.

Input Parameters

Name Type Description
configId Id The ID of the Version_Config__c object to return.

Return Value

The Version_Config__c object with the given ID.

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 configId = Id.valueOf('a3j1a0000008uAP'); // assume that we already have the Id from elsewhere.

pse__Version_Config__c fullConfig = VersionConfigService.getConfigById(configId);

getVersionCaptureConfigById

global static pse.VersionConfigService.VersionCaptureConfig getVersionCaptureConfigById(Id configId)

This method returns the VersionCaptureConfig object with the ID as passed in.

Input Parameters

Name Type Description
configId Id The ID of the VersionCaptureConfig object to return.

Return Value

The VersionCaptureConfig object with the given ID.

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 configId = Id.valueOf('a3j1a0000008uAP'); // assume that we already have the Id from elsewhere.

pse.VersionConfigService.VersionCaptureConfig fullConfig = VersionConfigService.getVersionCaptureConfigById(configId);

pse.VersionConfigService.VersionConfigDetails

global class VersionConfigDetails

Lightweight DTO for the details of the Version_Config__c object excluding the Capture_Config__c field. Used for quickly saving changes to the object such as Unique_Name__c and Default__c

Properties

Name Type Description
ConfigId Id The Salesforce ID of the Version_Config__c record represented by this DTO.
Name String The unique name of the Version_Config__c.
Summary String A description of the configuration.
IsDefault Boolean A flag to indicate whether this configuration is the one used when creating baselines and versions of not.
LastModifiedDate Datetime The Salesforce timestamp showing when the record was last changed.

pse.VersionConfigService.VersionCaptureConfig

global class VersionCaptureConfig

A representation of the whole capture configuration.
The capture configuration is stored on the pse__Version_Config__c.Capture_Config__c field in JSON format.

Properties

Name Type Description
VersionedObjects pse.VersionConfigService.VersionCaptureObject[] An array of all the objects you want to version as part of the configuration.

pse.VersionConfigService.VersionCaptureObject

global class VersionCaptureObject

A representation of an object you want to version.

Properties

Name Type Description
VersionedFields pse.VersionConfigService.VersionCaptureField[] An array of fields you want to version.
OriginalIdField String The API name of the field on the destination object that holds the ID of the original object.
OriginatorAPIName String The API name of the SObject you are versioning.
OriginatorProjectLookupFieldAPIName String The API name of the field on the original object that is the relationship used to link to the project you are versioning.
DestinationAPIName String The API name of the destination SObject that holds the content from the original record used to generate a version.
DestinationVersionLookupFieldAPIName String The API name of the field with a relationship to the master Version__c record. This field relationship can be a lookup or master detail.

pse.VersionConfigService.VersionCaptureField

global class VersionCaptureField

A representation of the field you want to capture.

Properties

Name Type Description
OriginatorFieldAPIName String The API name of the field you want to capture from.
DestinationFieldAPIName String The API name of the field on the destination record to hold the copied value from the original record.
© Copyright 2009–2018 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.