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:

SimpleVcs
const vcs = new SimpleVcs();

createTableSnapshot(tableName)


Use this method to create an up-to-date version of all records in the specified table.

Parameter(s):

NameTypeMandatoryDefault value
tableNameStringYN

Return:

TypeDescription
IntegerThe method returns the number of versions created.

Example:

createTableSnapshot
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):

NameTypeMandatoryDefault value
sysVcsLocalPackIdStringYN

Return:

TypeDescription
ObjectThe method returns SOP file for downloading.

Example:

exportLocalPackVcsRecords
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.

Parameter(s):

NameTypeMandatoryDefault value
retrievedPackIdStringYN

Return:

TypeDescription
BooleanThe method returns true if the records are imported; otherwise, it returns false.

Example:

importRetrievedPack
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):

NameTypeMandatoryDefault value
localPackIdStringYN

Return:

TypeDescription
BooleanThe method returns true if it finds the records; otherwise, it returns false.

Example:

isLocalPackHasReferences
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):

NameTypeMandatoryDefault value
retrievedPackIdStringYN

Return:

TypeDescription
BooleanThis method returns true if there are any references to records; otherwise, it returns false.

Example:

isRetrievedPackHasReferences
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):

NameTypeParameterDefault value
sysVcsRetrievedPackIdStringYN

Return:

TypeDescription
BooleanThis method returns true if data loading was successful; otherwise, it returns false.

Example:

loadDataFromAttachment
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):

NameTypeMandatoryDefault value
rowIdsArray of StringsYN
nameStringNmerged pack
descriptionStringNN

Return:

TypeDescription
StringThe method returns the ID of the merged local pack if successful; otherwise, it returns null.

Example:

mergeLocalPacks
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

versionIdsArray of StringsYN

Return:

Type

Description

BooleanThis method returns true if the moving was successful; otherwise, it returns false.

Example:

moveVcsRecordsToDefault
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):

NameTypeMandatoryDefault value
retrievedPackIdStringYN

Return:

TypeDescription
BooleanThis method returns true if preview was successful; otherwise, it returns false.

Example:

preview
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 rollbacked when it is in the Rollback previewed state.

Parameter(s):

NameTypeMandatoryDefault value
packIdStringYN

Return:

TypeDescription
VoidThe method does not return a value.

Example:

rollback
const vcsLocalPackId = '156144163704236641';
const vcs = new SimpleVcs();
vcs.rollBack(vcsLocalPackId);

rollBackPreview(packId)


Use this method to preview the rollback results.

Parameter(s):

NameTypeMandatoryDefault value
packIdStringYN

Return:

TypeDescription
VoidThe method does not return a value.

Example:

rollBackPreview
const vcsLocalPackId = '156144163704236641';
const vcs = new SimpleVcs();
vcs.rollBackPreview(vcsLocalPackId);