TSService.rollbackRevision

Syntax

rollbackRevision (wbk, metaData, callback);

Parameters

wbk. Sets workbook value.

metaData. Sets metadata that include information on revisions and time series database.

callback. Sets handler for operation execution end.

Description

The rollbackRevision method rolls back revisions.

Example

To execute the example, the page must contain the WorkbookBox component named workbookBox (see Example of Creating the WorkbookBox Component), and also add the following code in the handler, that processes document opening event:

var rollbackRevisionsButt = new PP.Ui.Button({
	ParentNode: document.body, //DOM parent node
	Content: "Revision Rollback", //text
	Click: PP.Delegate(onClickCallback)
});
function onClickCallback()
	{
		var rubKey = wbk.getActiveSheet().getRub().meta.obInst.obDesc.k;
		var wbkPB = workbookBox.getPropertyBarView();
		var panels = wbkPB._selfNavItems;
		var revisionsPanel = null;
		var i;
		//Get panel of time series database revisions
		for (i = 0; i < panels.length; i++)
			{
				if (panels[i]._GroupName == PP.TS.Ui.PropertyGroups.RubricatorRevisions && panels[i].getTag() == rubKey)
					{
						revisionsPanel = wbkPB._selfNavItems[i];
						break;
					}
			}
		//Get the selected element of revisions list
		var sitem = revisionsPanel._RevisionsListBox.getSelectedItem();
		if (!sitem)
		return;
		var revKey = sitem.getId();
		var metadata =
			{
				"Comment": "Rollback",
				"Operation": "Rollback",
				"RevKey": revKey,
				"RubKey": wbk.getActiveSheet().getRub().meta.obInst.obDesc.k
			}
		//Rollback revision
		tsService.rollbackRevision(wbk, metadata, PP.Delegate(onResponse));
		function onResponse(sender, args)
			{
				//Get a list of revisions in the obtained server response 
				var res = JSON.parse(args.ResponseText);
				var revs = res.GetRubMdResult.meta.revisions.its.it;
				//Set a new list of revisions in the revisions panel
				revisionsPanel.setRevisions(revs);
			}
	}

After executing the example the HTML page will contain a button named Revision Rollback. To execute the example, open a panel with the database name in the Data tab of the properties panel, and select one of the available revisions. Next click the Rollback Revision button, a new revision named RollbackData appears in the panel. Date of this revision creation is also displayed.

See also:

TSService