pse.VersionConfigServiceglobal class VersionConfigService Methods
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(); 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); deleteVersionConfigDetailsglobal static void deleteVersionConfigDetails(List<Id> configIds) This method deletes the Version_Config__c objects associated with the given list of IDs. 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); 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); pse.VersionConfigService.VersionConfigDetailsglobal 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
pse.VersionConfigService.VersionCaptureConfigglobal class VersionCaptureConfig A representation of the whole capture configuration. Properties
pse.VersionConfigService.VersionCaptureObjectglobal class VersionCaptureObject A representation of an object you want to version. Properties
pse.VersionConfigService.VersionCaptureFieldglobal class VersionCaptureField A representation of the field you want to capture. Properties
|