Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This server-side class is necessary for using the SimpleOne version control system (VCS).

SimpleVcs()


Instantiates a new empty SimpleVcs class object.

Example:

Code Block
languagejs
themeEclipse
titleSimpleVcs
linenumberstrue
const vcs = new SimpleVcs();


createTableSnapshot(tableName)


This method creates initial versions of all the records of the specified table.


Parameter(s):

NameTypeMandatoryDefault Value
tableNameStringYN


Return:

TypeDescription
BooleanIntegerThis method returns TRUE if the snapshot was successful; otherwise, it returns FALSEnumber of versions created after the script has executed.


Example:

Code Block
languagejs
themeEclipse
titlecreateTableSnapshot
linenumberstrue
letconst tableName = ‘Incident’'sys_script';
letconst vcs = new SimpleVcsApiSimpleVcs();
letconst snapshotStateversionCount = vcs.createTableSnapshot(tableName);
if (snapshotState) {
	ss.info(‘Success’versionCount)
}; else {
	ss.info(‘Houston we have a problem with creating snapshot);
}// 1

exportLocalPackVcsRecords(sysVcsLocalPackId)


This method performs VCS records export that were bound to the localpack configuration pack with the unique ID $sysVcsLocalPackId as a .SOP file. This pack must be in the Completed state.


Parameter(s):

NameTypeMandatoryDefault Value
sysVcsLocalPackIdIntegerYN


Return:

TypeDescription
ObjectReturns a .SOP file for downloading.


Example:

Code Block
languagejs
themeEclipse
titleexportLocalPackVcsRecords
linenumberstrue
letconst vcsLocalPackId = '156144163704236641';
letconst vcs = new SimpleVcsApiSimpleVcs();
vcs.exportLocalPackVcsRecords(vcsRetrievedPackId);

importRetrievedPack(retrievedPackId)


This method imports the last containing in the VCS preview log (sys_vcs_preview_log) table previewed retrieved pack to the VCS Record (sys_vcs_record) table.


Parameter(s):

NameTypeMandatoryDefault Value
retrievedPackIdIntegerYN


Return:

TypeDescription
StringReturns string containing the import results.


Example:

Code Block
languagejs
themeEclipse
titleimportRetrievedPack
linenumberstrue
letconst vcsRetrievedPackId = '156144163704236641';
letconst vcs = new SimpleVcsApiSimpleVcs();
letconst result = vcs.importRetrievedPack(vcsRetrievedPackId);
ss.addInfoMessage(result);

isLocalPackHasReferences(localPackId)


This method checks the record from the sys_vcs_local_pack table if it has referenced current* records from the the VCS records (sys_vcs_record) table.

*the current records have the is_current attribute equal to TRUE.


Parameter(s):

NameTypeMandatoryDefault Value
localPackIdIntegerYN


Return:

TypeDescription
BooleanThe method returns TRUE if it finds theserecords'true' if it finds records of such kind; otherwise, it returns FALSE'false'.


Example:

Code Block
languagejs
themeEclipse
titleisLocalPackHasReferences
linenumberstrue
letconst vcsLocalPackId = '156144163704236641';
letconst vcs = new SimpleVcsApiSimpleVcs();
if (vcs.isLocalPackHasReferences(vcsLocalPackId)) {
  ss.addInfoMessage('Local Pack has current VCS records');
}

isRetrievedPackHasReferences(retrievedPackId)


This method checks the record from the the VCS Retrieved pack (sys_vcs_retrieved_pack) table if it has referenced records from the records from the VCS Records (sys_vcs_record) table.


Parameter(s):

NameTypeMandatoryDefault Value
retrievedPackIdIntegerYN


Return:

TypeDescription
BooleanThis method returns TRUE 'true' if there are any referenced records; otherwise, it returns FALSE'false'.


Example:

Code Block
languagejs
themeEclipse
titleisRetrievedPackHasReferences
linenumberstrue
letconst vcsRetrievedPackId = '156144163704236641';
letconst vcs = new SimpleVcsApiSimpleVcs();
if (vcs.isRetrievedPackHasReferences(vcsRetrievedPackId)) {
  ss.addInfoMessage('Retrieved Pack has current VCS records');
}

isRetrievedPackHasAttache(vcsRetrievedPackId)



Warning

This method has been deprecated since version 1.2 and no longer supported. Please use the hasAttachment() method instead.


loadDataFromAttachment(sysVcsRetrievedPackId)


This method loads configuration pack data from attachment provided to the Retrieved Records ( checks the record from the sys_vcs_retrieved_pack table if it has an attached file.Parameter(s):record) table for the preview purposes.


NameType
Mandatory
ParameterDefault Value
vcsRetrievedPackId
sysVcsRetrievedPackIdIntegerYN


Return:

TypeDescription
BooleanThis method returns
TRUE if there are any attached files
'true' if data loading was successful; otherwise, it returns
FALSE
'false'.


Example:

Code Block
languagejs
themeEclipse
titleisRetrievedPackHasAttacheloadDataFromAttachment
linenumberstrue
letconst vcsRetrievedPackIdvcs = new 156144163704236641SimpleVcs();
letconst vcsmessage = new SimpleVcsApiSimpleMessage();
if (!vcs.isRetrievedPackHasAttache(vcsRetrievedPackIdloadDataFromAttachment(current.sys_id)) {
  ss.addInfoMessageaddErrorMessage('RetrievedError Pack has attached file')loading data');
  return;
}
ss.setRedirect();

mergeLocalPacks(rowIds, name, description)


This method implements merging miltiple multiple localpacks into one. Herewith, initial localpack are being removed irrevocably.


Parameter(s):

NameTypeMandatoryDefault Value
rowIdsArrayYN
nameStringN'merged pack'
descriptionStringN'merged pack description'N


Return:

TypeDescription
StringReturns ID of the resulting merged localpack if successful; otherwise, it returns NULL'null'.


Example:

Code Block
languagejs
themeEclipse
titlemergeLocalPacks
linenumberstrue
letconst packIdsvcsLocalPackId = [
156144163704236641  '157666651911972694',
156144163704236642  '157665759017038346',
156144163704236643  '157665742419415102'
];
letconst mergedName = ‘Merged'Merged Pack 1’1';
letconst mergedDesc = ‘Merged'Merged Pack description 1’1';
letconst vcs = new SimpleVcsApiSimpleVcs();
letconst mergedId = vcs.mergeLocalPacks(vcsRetrievedPackIdvcsLocalPackId, mergedName, mergedDesc);
if (mergedId != null) {
	  ss.info(‘Merged'Merged Local Pack has Id ' + mergedId);
} else {
	  ss.info(‘Houston'Houston we have a problem with merging Packs’)

previewLastAttachedRetrievedPack(retrievedPackId)

 Packs');
}


moveVcsRecordsToDefault(versionIds)


This method allows bulk moving VCS records to the default local pack.

Parameter(s):

Name

Type

Mandatory

Default Value

versionIdsArrayYN

Return:

Type

Description

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


Code Block
languagejs
themeEclipse
titlemoveVcsRecordsToDefault
linenumberstrue
const vcs = new SimpleVcs();
const result = vcs.moveVcsRecordsToDefault([current.sys_id]);
ss.info(result);

preview(sysVcsRetrievedPackId)


This method extracts records related to the configuration from the Retrieved Records (sys_vcs_retrieved_record) table and performs a pack preview.This method provides the retrieved pack preview which can be also called "preimport". The pack must be in new or previewed state.


Parameter(s):

NameTypeMandatoryDefault Value
retrievedPackIdIntegerYN


Return:

TypeDescription
StringReturns the preview results
BooleanThis method returns 'true' if preview was successful; otherwise, it returns 'false'.


Example:

Code Block
languagejs
themeEclipse
titlepreviewLastAttachedRetrievedPackpreview
linenumberstrue
letconst vcsRetrievedPackIdvcs = new 156144163704236641SimpleVcs();
letconst vcsmessage = new SimpleVcsApiSimpleMessage();
let result = vcs.previewLastAttachedRetrievedPack(vcsRetrievedPackId);
ss.addInfoMessage(result
if (!vcs.preview(current.sys_id)) {
    const localizedMessage = message.getMessage('Error previewing data');
    ss.addErrorMessage(localizedMessage);
    return;
}
ss.setRedirect();


rollback(packId)


This method rollbacks a localpack. The localpack can be rollbacked only when it in the RollBack-Previewed state.


Parameter(s):

NameTypeMandatoryDefault Value
packIdIntegerYN


Return:

TypeDescription
StringReturns TRUE 'true' if rollback was successful; otherwise; throws an exception.


Example:

Code Block
languagejs
themeEclipse
titlerollback
linenumberstrue
letconst vcsLocalPackId = '156144163704236641';
letconst vcs = new SimpleVcsApiSimpleVcs();
if (vcs.rollBack(vcsLocalPackId)) {
  ss.addInfoMessage('RollBack of Local Pack was successful');
}


rollBackPreview(packId)



Parameter(s):

NameTypeMandatoryDefault Value
packIdIntegerYN


Return:

TypeDescription
BooleanReturns TRUE 'true' if the rollback preview was successful; otherwise, returns FALSE'false'.


Example:

Code Block
languagejs
themeEclipse
titlerollBackPreview
linenumberstrue
letconst vcsLocalPackId = '156144163704236641';
letconst vcs = new SimpleVcsApiSimpleVcs();
if (vcs.rollBackPreview(vcsLocalPackId)) {
  ss.addInfoMessage('RollBack preview of Local Pack was successful');
}


Table of Contents
absoluteUrltrue
classfixedPosition