SimpleVcs
This server-side class provides methods for using the SimpleOne version control system (VCS).
SimpleVcs()
Use this constructor to instantiate a new empty object of the SimpleVcs class.
Example:
const vcs = new SimpleVcs();
applyRetrievedPack(retrievedPackId)
Use this method after the importRetrievedPack() method to apply the created version of the imported pack.
Parameters:
Name | Type | Mandatory | Default value |
---|---|---|---|
retrievedPackId | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | The method returns true, if the local pack has been applyed. Otherwise, the method returns false. |
Example:
const vcs = new SimpleVcs();
const message = new SimpleMessage();
if (!vcs.importRetrievedPack(current.sys_id)) {
const localizedMessage = message.getMessage('Error importing data');
ss.addErrorMessage(localizedMessage);
return;
}
if (!vcs.applyRetrievedPack(current.sys_id)) {
const localizedMessage = message.getMessage('Error applying data');
ss.addErrorMessage(localizedMessage);
return;
}
createTableSnapshot(tableName)
Use this method to create an up-to-date version of all records in the specified table.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
tableName | String | Y | N |
Return:
Type | Description |
---|---|
Integer | The method returns the number of versions created. |
Example:
const tableName = 'sys_script';
const vcs = new SimpleVcs();
const versionCount = vcs.createTableSnapshot(tableName);
ss.info(versionCount); // 1
exportLocalPackVcsRecords(sysVcsLocalPackId)
Use this method to export a SOP file of the VCS records that are bound to the configuration pack with a unique ID. This pack must be in the Completed state.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
sysVcsLocalPackId | String | Y | N |
Return:
Type | Description |
---|---|
Object | The method returns SOP file for downloading. |
Example:
const vcsLocalPackId = '156144163704236641';
const vcs = new SimpleVcs();
vcs.exportLocalPackVcsRecords(vcsRetrievedPackId);
importRetrievedPack(retrievedPackId)
Use this method to import the records of the retrieved pack that are uploaded in the VCS Preview Log (sys_vcs_preview_log) table to the VCS Record (sys_vcs_record) table. This method creates a version of the pack. To apply the pack, use the applyRetrievedPack() method.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
retrievedPackId | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | The method returns true if the records are imported; otherwise, it returns false. |
Example:
const vcsRetrievedPackId = '156144163704236641';
const vcs = new SimpleVcs();
const result = vcs.importRetrievedPack(vcsRetrievedPackId);
ss.addInfoMessage(result);
isLocalPackHasReferences(localPackId)
Use this method to check the record from the VCS Local Pack (sys_vcs_local_pack) table for references to the current* records from the VCS Record (sys_vcs_record) table.
*the current records have the selected Is current checkbox.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
localPackId | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | The method returns true if it finds the records; otherwise, it returns false. |
Example:
const vcsLocalPackId = '156144163704236641';
const vcs = new SimpleVcs();
if (vcs.isLocalPackHasReferences(vcsLocalPackId)) {
ss.addInfoMessage('Local Pack has current VCS records');
}
isRetrievedPackHasReferences(retrievedPackId)
Use this method to check the record from the VCS Retrieved pack (sys_vcs_retrieved_pack) table for references to the records from the VCS Records (sys_vcs_record) table.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
retrievedPackId | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if there are any references to records; otherwise, it returns false. |
Example:
const vcsRetrievedPackId = '156144163704236641';
const vcs = new SimpleVcs();
if (vcs.isRetrievedPackHasReferences(vcsRetrievedPackId)) {
ss.addInfoMessage('Retrieved Pack has current VCS records');
}
isRetrievedPackHasAttache(vcsRetrievedPackId)
This method has been deprecated since version 1.2 and is no longer supported. Use the hasAttachment() method instead.
loadDataFromAttachment(sysVcsRetrievedPackId)
Use this method to load data from a configuration pack that has been added to the Retrieved Records (sys_vcs_retrieved_record) table record as a preview attachment.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
sysVcsRetrievedPackId | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if data loading was successful; otherwise, it returns false. |
Example:
const vcs = new SimpleVcs();
const message = new SimpleMessage();
if (!vcs.loadDataFromAttachment(current.sys_id)) {
ss.addErrorMessage('Error loading data');
return;
}
ss.setRedirect();
mergeLocalPacks(rowIds, name, description)
Use this method to merge multiple local packs into one. The original local packs are permanently removed.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
rowIds | Array of Strings | Y | N |
name | String | N | merged pack |
description | String | N | N |
Return:
Type | Description |
---|---|
String | The method returns the ID of the merged local pack if successful; otherwise, it returns null. |
Example:
const vcsLocalPackId = [
'157666651911972694',
'157665759017038346',
'157665742419415102'
];
const mergedName = 'Merged Pack 1';
const mergedDesc = 'Merged Pack description 1';
const vcs = new SimpleVcs();
const mergedId = vcs.mergeLocalPacks(vcsLocalPackId, mergedName, mergedDesc);
if (mergedId != null) {
ss.info('Merged Local Pack has Id ' + mergedId);
} else {
ss.info('Houston we have a problem with merging Packs');
}
moveVcsRecordsToDefault(versionIds)
Use this method to move many VCS records to the default local pack.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
versionIds | Array of Strings | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if the moving was successful; otherwise, it returns false. |
Example:
const vcs = new SimpleVcs();
const result = vcs.moveVcsRecordsToDefault([current.sys_id]);
ss.info(result);
preview(sysVcsRetrievedPackId)
Use this method to extract the records related to the configuration from the Retrieved Records (sys_vcs_retrieved_record) table and perform a pack preview.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
retrievedPackId | String | Y | N |
Return:
Type | Description |
---|---|
Boolean | This method returns true if preview was successful; otherwise, it returns false. |
Example:
const vcs = new SimpleVcs();
if (!vcs.preview(current.sys_id)) {
ss.addErrorMessage(localizedMessage);
return;
}
ss.setRedirect();
rollback(packId)
Use this method to roll back a local pack. The local pack can only be roll backed when it is in the Rollback previewed state.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
packId | String | Y | N |
Return:
Type | Description |
---|---|
Void | The method does not return a value. |
Example:
const vcsLocalPackId = '156144163704236641';
const vcs = new SimpleVcs();
vcs.rollBack(vcsLocalPackId);
rollBackPreview(packId)
Use this method to preview the rollback results.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
packId | String | Y | N |
Return:
Type | Description |
---|---|
Void | The method does not return a value. |
Example:
const vcsLocalPackId = '156144163704236641';
const vcs = new SimpleVcs();
vcs.rollBackPreview(vcsLocalPackId);