pse.VersionConfigServiceglobal with sharing class VersionConfigService Service to create, modify and validate custom configurations for Project Versioning and Baselines. Methods
deleteVersionConfigDetailsglobal static void deleteVersionConfigDetails(List<Id> configIds) This method deletes the Version_Config__c objects with the list of IDs as passed in. Input Parameters
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); getActiveVersionConfigglobal 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 ValueThe 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(); getAllVersionConfigDetailsglobal 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 ValueList 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); getConfigByIdglobal static pse__Version_Config__c getConfigById(Id configId) This method returns the Version_Config__c object with the ID as passed in. Input Parameters
Return ValueThe 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); getVersionCaptureConfigByIdglobal static pse.VersionConfigService.VersionCaptureConfig getVersionCaptureConfigById(Id configId) This method returns the VersionCaptureConfig object with the ID as passed in. Input Parameters
Return ValueThe 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); saveCaptureConfigglobal 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
Return ValueThe 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); saveVersionConfigDetailsglobal 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
Return ValueUpdated 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); validateCaptureConfigglobal static pse.VersionConfigService.ValidationResult[] validateCaptureConfig(Id[] configIds) This method retrieves the Version_Config__c records with the given IDs and validates the VersionCaptureConfigs contained within. Input Parameters
Return ValueReturns a list of validation results. One result per ID is returned in the order as given. 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 newConfig = pse.VersionConfigService.getCloneOfPSAPackagedDefault(); newConfig.pse__Unique_Name__c = 'My copy of default config'; insert newConfig; pse__Version_Config__c existingConfig = [SELECT Id FROM pse__Version_Config__c WHERE pse__Unique_Name__c = 'Time and material config']; List<Id> configIdsToValidate = new List<Id>(); configIdsToValidate.add(newConfig.Id); configIdsToValidate.add(existingConfig.Id); configIdsToValidate.add('a3ff400000066RUAAY'); pse.VersionConfigService.ValidationResult[] results = pse.VersionConfigService.validateCaptureConfig(configIdsToValidate); for(pse.VersionConfigService.ValidationResult result : results) { if(result.HasFailed) { for (pse.VersionConfigService.ValidationRecordWrapper wrapper : result.FailedRecords) { // What went wrong? System.debug(wrapper.ErrorMessage); // With what part? System.debug(wrapper.OriginatorLabel + ' ' + wrapper.DestinationLabel + ' ' + wrapper.FieldLabel); } } } validateCaptureConfigglobal static pse.VersionConfigService.ValidationResult[] validateCaptureConfig(pse.VersionConfigService.VersionCaptureConfig[] captureConfigs) This method validates the given VersionCaptureConfig objects. Input Parameters
Return ValueReturns a list of validation results. One result per ID is returned in the order as passed. 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 newConfig = pse.VersionConfigService.getCloneOfPSAPackagedDefault(); newConfig.pse__Unique_Name__c = 'My copy of default config'; pse__Version_Config__c existingConfig = [SELECT Id, pse__Capture_Config__c FROM pse__Version_Config__c WHERE pse__Unique_Name__c = 'Time and material config']; List<pse.VersionConfigService.VersionCaptureConfig> configsToValidate = new List<pse.VersionConfigService.VersionCaptureConfig>(); pse.VersionConfigService.VersionCaptureConfig newCaptureConfigDTO = (pse.VersionConfigService.VersionCaptureConfig) JSON.deserialize(newConfig.pse__Capture_Config__c, pse.VersionConfigService.VersionCaptureConfig.class); pse.VersionConfigService.VersionCaptureConfig existingCaptureConfigDTO = (pse.VersionConfigService.VersionCaptureConfig) JSON.deserialize(existingConfig.pse__Capture_Config__c, pse.VersionConfigService.VersionCaptureConfig.class); configsToValidate.add(newCaptureConfigDTO); configsToValidate.add(existingCaptureConfigDTO); pse.VersionConfigService.ValidationResult[] results = pse.VersionConfigService.validateCaptureConfig(configsToValidate); for(pse.VersionConfigService.ValidationResult result : results) { if(result.HasFailed) { for (pse.VersionConfigService.ValidationRecordWrapper wrapper : result.FailedRecords) { // What went wrong? System.debug(wrapper.ErrorMessage); // With what part? System.debug(wrapper.OriginatorLabel + ' ' + wrapper.DestinationLabel + ' ' + wrapper.FieldLabel); } } } pse.VersionConfigService.VersionConfigDetailsglobal inherited sharing 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
MethodsVersionConfigDetailsglobal VersionConfigDetails() pse.VersionConfigService.VersionCaptureConfigglobal inherited sharing class VersionCaptureConfig A representation of the whole capture configuration. Properties
MethodsVersionCaptureConfigglobal VersionCaptureConfig() pse.VersionConfigService.VersionCaptureObjectglobal inherited sharing class VersionCaptureObject A representation of an object you want to version. Properties
MethodsVersionCaptureObjectglobal VersionCaptureObject() pse.VersionConfigService.VersionCaptureFieldglobal inherited sharing class VersionCaptureField A representation of the field you want to capture. Properties
MethodsVersionCaptureFieldglobal VersionCaptureField() pse.VersionConfigService.ValidationResultglobal inherited sharing class ValidationResult An instance of this object contains the results of a validation. Properties
MethodsValidationResultglobal ValidationResult() pse.VersionConfigService.ValidationFailureglobal inherited sharing class ValidationFailure An object denoting a failure in the VersionConfigValidator, to be created from a ValidationResultWrapper. Properties
MethodsValidationFailureglobal ValidationFailure() |