Class

SpotfireDocument

SpotfireDocument(serverUrlOrDocumentParametersObject, [documentPath], [onDocumentOpened], [configurationBlockText], [apiVersion], [initClientOptions])

Object allowing to access the TIBCO Spotfire® document and to edit it via its editor property.

Constructor

new SpotfireDocument(serverUrlOrDocumentParametersObject, [documentPath], [onDocumentOpened], [configurationBlockText], [apiVersion], [initClientOptions])

Parameters:
Name Type Default Description
serverUrlOrDocumentParametersObject String | DocumentParametersObject

The Spotfire Server url, of the form 'http(s)://[server][:port]/spotfire/wp or the DocumentParametersObject.

serverUrl String

The Spotfire Server url, of the form 'http(s)://[server][:port]/spotfire/wp or the DocumentParametersObject.

documentPath String

The complete path to the library document or its GUID..

[ onDocumentOpened ] onDocumentOpenedEventHandler

The callback that will be executed after the document is opened.

[ err ] Error

The error that may have occurred or undefined.

[ configurationBlockText ] String

The configuration block text that will be applied after the document is opened.

[ apiVersion = '7.14' ] String

The webplayer apiVersion (for Spotfire 7.14+).

[ initClientOptions ] InitClientOptions

specific options to be used for web player UI customization

[ pageIndex ] String

The page index to be opened at start

[ targetDiv ] String

The location of the iframe for the Web Player

[ customization ] Object

The customization options. See https://docs.tibco.com/pub/sfire_dev/area/doc/api/TIB_sfire_Web_Player_JavaScript_API_Reference/html/T_spotfire_webPlayer_Customization.htm#! for details

[ onCreateLoginElement ] onCreateLoginElement

The callback that returns a clickable DOM element to login to spotfire if needed

[ reloadInstances ] Boolean

Maps the reloadInstances option from Spotfire JS API (WebPlayer only)

[ emptyDocumentOnOpen ] Boolean

Whether to remove all data tables from the document on open opened.

[ modApi ] Object

The mods API, to be used from spotfire 11.0 in a Mod context (Custom visualization)

[ customPythonToolConfiguration ] CustomPythonToolConfiguration

The configuration to create a webconnector that use custom python tool for execution of python script

[ documentPath = "/Discngine/Client Automation/empty" ] String

The complete path to the library document.

[ onDocumentOpened ] onDocumentOpenedEventHandler

The callback that will be executed after the document is opened.

[ err ] Error

The error that may have occurred or undefined.

[ configurationBlockText ] String

The configuration block text that will be applied after the document is opened.

[ apiVersion = '7.14' ] String

The Web Player apiVersion (for Spotfire 7.14+).

[ initClientOptions ] InitClientOptions

The Web Player init client options.

[ pageIndex ] String

The page index to be opened at start

[ targetDiv ] String

The location of the iframe for the Web Player

[ customization ] Object

The customization options. See https://docs.tibco.com/pub/sfire_dev/area/doc/api/TIB_sfire_Web_Player_JavaScript_API_Reference/html/T_spotfire_webPlayer_Customization.htm#! for details

[ onCreateLoginElement ] onCreateLoginElement

The callback that returns a clickable DOM element to login to spotfire if needed

Members

editor

An instance of SpotfireDocumentEditor bound to the current SpotfireDocument instance. Use it to apply modifications to the Spotfire Document.

Example
// Script to add a Bar Chart and Table Plot to the document
 spotfireDocument.editor
   .addBarChart()
   .addTable()
   .applyState();

saveAsync

Asynchronous version of the SpotfireDocument.save method.

Methods

static checkSaveLibraryPath()

Throws an exception if the library path passed as args is not a correctly formed path.

If the path is not a correctly formed spotfire library path

Error

applyTemplateAsync(applyParameters) → {Promise}

Apply a template to the current document.
A template is a document with empty data tables. During the process, the data tables are temporarily exported into SBDF files of the same name and with the extension '.export.sbdf', in the same place as the template. We therefore advise you to make sure that no SBDF files with these names are present in the location of the template to apply, otherwise they will be deleted.
Other warning: once the template is applied, it becomes the current document, so the template can easily be overwritten by accident. A solution to avoid this may be to save the document as a new one, using the SpotfireDocument.save function (see the examples).

Parameters:
Name Type Default Description
applyParameters Object

Describes the parameters needed to apply the template.

path String

The path of the template.

fileName String

The name of the template to be applied.

[ configurationBlockText ] String

The configuration block text that shall be used to perform an initial configuration of the document after it has been opened.

[ location = SpotfireDocument.library ] SpotfireDocumentLocation  {Enum} 

The location where the document is saved.

Enum options: library, local
Promise
Examples

Apply a template from the library:

spotfireDocument.applyTemplateAsync({
    path: '/Discngine/Client Automation',
    fileName: 'myNewTemplate',
    configurationBlockText: 'myKey1="ATextToSave";myKey2=255;'
})

Apply a template from a local file:

spotfireDocument.applyTemplateAsync({
    path: 'C:/temp',
    fileName: 'myNewTemplate',
    location: 'Local'
})

clearMarkingAsync(markingName, dataTableName)

Clear the selection for the specified marking and table

Parameters:
Name Type Description
markingName String

The marking name in which to set the marking.

dataTableName String

The data table in which to set the marking.

closeDocument()

Close the current document.

createWhereClauseForColumnAndValues(idColumnName, ids)

Helper method used to create clause expression for a specific column and a set of values that may be in it.

Parameters:
Name Type Description
idColumnName String

The name of the column that will contains the ids searched.

ids Array.<string> | Array.<boolean> | Array.<numeric>

The list of values searched.

Example
spotfireDocument.createWhereClauseForColumnAndValues('Column Name', ['ID1', 'ID2', 'ID3', 'ID4'])
// => [Column Name]="ID1" OR [Column Name]="ID2" OR [Column Name]="ID3" OR [Column Name]="ID4"

dispose()

Disposes all resources that must be disposed and clear all events listeners.

doMandatoryDocumentChangedActions()

Method always called when a document is changed (opened or closed).

doMandatoryDocumentClosedActions()

Method always called when a document is closed.

executePythonScript(scriptText, scriptArgs)

Execute a python script on the document synchronously. We suggest to avoid using it unless necessary because of its detrimental effect on performance.

Parameters:
Name Type Description
scriptText String

The script to be executed.

scriptArgs Object

The list of named parameters that may be used in the script. In python script the args will be used as jsonParam[].

Example
// Script to hide the column "Column To Hide" from a Table Plot
const hideColumnScript = `
for p in Document.Pages:
for v in p.Visuals:
    if v.TypeId.Name == "Spotfire.Table":
    chart = v.As[TablePlot]()
    (found, column) = chart.Data.DataTableReference.Columns.TryGetValue(jsonParam["columnName"])
    if found:
        chart.TableColumns.Remove(column)
 `;
 spotfireDocument.executePythonScript(hideColumnScript, { columnName: "Column To Hide" });

executePythonScriptAndGetValueAsync(scriptText, scriptArgs) → {Promise}

Execute a python script on the document asynchronously and retrieve the result in a promise. We suggest to avoid using it unless necessary because of its detrimental effect on performance. To get the result, use the python functions setResultProperty(serializeToJSON()) at the end of your script.

Parameters:
Name Type Description
scriptText String

The script to be executed.

scriptArgs Object

The list of named parameters that may be used in the script. In python script the args will be used as jsonParam[].

Promise
Example
// Script to get the list of all visualizations in the Spotfire document
const getVisualizationsScript = `
titles = []
for p in Document.Pages:
    for v in p.Visuals:
        titles.append(v.Title)
setResultProperty(serializeToJSON(titles))
`;
spotfireDocument.executePythonScriptAndGetValueAsync(getVisualizationsScript, {}).then(alert);

executePythonScriptAsync(scriptText, scriptArgs) → {Promise}

Execute a python script on the document asynchronously. We suggest to avoid using it unless necessary because of its detrimental effect on performance.

Parameters:
Name Type Description
scriptText String

The script to be executed.

scriptArgs Object

The list of named parameters that may be used in the script. In python script the args will be used as jsonParam[].

Promise
Example
// Script to hide the column "Column To Hide" from a Table Plot
const hideColumnScript = `
for p in Document.Pages:
    for v in p.Visuals:
        if v.TypeId.Name == "Spotfire.Table":
            chart = v.As[TablePlot]()
            (found, column) = chart.Data.DataTableReference.Columns.TryGetValue(jsonParam["columnName"])
            if found:
                chart.TableColumns.Remove(column)
 `;
 spotfireDocument.executePythonScriptAsync(hideColumnScript, { columnName: "Column To Hide" }).then(() => alert('Column Hidden'));

exportTableAsync(exporterType, tableName, exporterArgs) → {Promise}

Parameters:
Name Type Description
exporterType String

The type of the exporter to be used.

tableName String

The TIBCO Spotfire® data table containing data to be exported.

exporterArgs Object

Exporter parameters to be used to export the data.

columns Array.<String>

Lists the columns to be exported.

filterRows Object

Settings used to limit the exported data.

type SpotfireFilterRowType  {Enum} 

Type of the filtering. Available in the SpotfireFilterRowType enum object.

Enum options: all, marking, filtering
name String

Name of the marking to be used to export data. If it is not precised, the active marking is used.

serverRoot String

The root URL of the Pipeline Pilot server.

sessionId String

The Pipeline Pilot session ID to be used.

destinationPath String

The path on the Pipeline Pilot server in which the file will be written.

destinationFile String

The SBDF file that will contain the exported data. If it leaves empty, the name of the data table will be used to name the file.

Promise
Examples
exporterArgs = {
 serverRoot: 'http://serverFQDN:port/',
 sessionId: 'AZERTYUIOIPSDJKLMD123456789',
 destinationPath: 'C:/Program Files/BIOVIA/PPS/web/jobs/myUserName/AABBCCDD1234'
};
spotfireDocument.exportTableAsync('PipelinePilot', 'aTable', exporterArgs);
exporterArgs = {
 serverRoot: 'http://serverFQDN:port/',
 sessionId: 'AZERTYUIOIPSDJKLMD123456789',
 destinationPath: 'C:/Program Files/BIOVIA/PPS/web/jobs/myUserName/AABBCCDD1234',
 filterRows: {
     type: SpotfireFilterRowType.marking
 },
 columns: ['Activity', 'ALogP']
};
spotfireDocument.exportTableAsync('PipelinePilot', 'aTable', exporterArgs);
exporterArgs = {
 serverRoot: 'http://serverFQDN:port/',
 sessionId: 'AZERTYUIOIPSDJKLMD123456789',
 destinationPath: 'C:/Program Files/BIOVIA/PPS/web/jobs/myUserName/AABBCCDD1234',
 destinationFile: 'markedData.sbdf'
 filterRows: {
     type: SpotfireFilterRowType.marking,
     name: 'Marking'
 }
};
spotfireDocument.exportTableAsync('PipelinePilot', 'aTable', exporterArgs);
exporterArgs = {
 serverRoot: 'http://serverFQDN:port/',
 sessionId: 'AZERTYUIOIPSDJKLMD123456789',
 destinationPath: 'C:/Program Files/BIOVIA/PPS/web/jobs/myUserName/AABBCCDD1234',
 destinationFile: 'markedData.sbdf'
 filterRows: {
     type: SpotfireFilterRowType.filtering
 }
};
spotfireDocument.exportTableAsync('PipelinePilot', 'aTable', exporterArgs);
Exporting a file on your local drive.
WARNING! ONLY WORKS IN ANALYST AS YOU DO NOT HAVE ACCESS TO FILE SYSTEM IN WEB PLAYER.
exporterArgs = {
 destinationPath: 'C:/Users/YourName/Documents',
 destinationFile: 'myTable.sbdf'
};
spotfireDocument.exportTableAsync('Local', 'aTable', exporterArgs);

getActiveDataTableAsync() → {Promise(String)}

Gets the name of the active data table.

A data table name.

Promise(String)

getActiveMarkingAsync() → {Promise(String)}

Gets the active marking name of the active visual.

Promise(String)

getDataColumnsAsync(dataTableName) → {Promise(String[])}

Gets the list of data table names with their identifiers.

Parameters:
Name Type Description
dataTableName String

The name of the data table.

An array of columns names.

Promise(String[])
Example
spotfireDocument.getDataColumnsAsync("Maybridge-200").then(console.log);
// outputs something like
['Column A', 'Column B', 'Column C']

getDataColumnsPropertiesAsync(dataTableName) → {Promise(DataTableColumnProperties[])}

Gets the list of properties for all columns of a data table.

Parameters:
Name Type Description
dataTableName String

The name of the data table.

Promise(DataTableColumnProperties[])
Example
spotfireDocument.getDataColumnsPropertiesAsync("My Data Table").then(console.log);
// outputs something like
[{
    contentType: "chemical/x-mdl-molfile",
    dataType: "Binary",
    description: "",
    expression: "",
    externalId: null,
    externalName: "Structure <MOLFILE>",
    name: "Structure <MOLFILE>"
},
{
    contentType: null,
    dataType: "String",
    description: "",
    expression: "",
    externalId: null,
    externalName: "CODE",
    name: "CODE"
}]

getDataFunctionFromLibraryAsync(pathOrGuid) → {Promise(DataFunctionDefinition)}

Retrieves the definition of a data function registered in the Spotfire Library.

Parameters:
Name Type Description
pathOrGuid String

path or GUID of the data function to get from the library.

The data function definition.

Promise(DataFunctionDefinition)

getDataTableContentAsync([table], [marking], [from], [to], [columns], [delimiter]) → {Promise(String)}

Gets the content of a data table in STDF format. Gets the whole data table or specific rows and/or columns.

Parameters:
Name Type Description
[ table ] String

The name of the data table.

[ marking ] String

The name of the marking.

[ from ] Number

The first row index of a range of rows.

[ to ] Number

The last row index of a range of rows.

[ columns ] String

The list of columns, concatenated with a delimiter.

[ delimiter ] String

The delimiter used for the list of columns.

The content of a data table.

Promise(String)

getDataTableNamesAsync() → {Promise(String[])}

Gets the names of all data tables in the document.

An array of data tables names.

Promise(String[])

getDataTablePropertiesAsync(dataTableName) → {Promise(DataTableProperty[])}

Gets the list of properties of the data table.

Parameters:
Name Type Description
dataTableName String

The name of the data table.

Promise(DataTableProperty[])
Example
spotfireDocument.getDataTablePropertiesAsync("My Data Table").then(console.log);
// outputs something like
[{
     name: "Color",
     value: {
         R: 100,
         G: 137,
         B: 250,
         A: 255,
         IsKnownColor: false,
         IsEmpty: false,
         IsNamedColor: false,
         IsSystemColor: false,
         Name: "ff6489fa"
     }
}, {
     name: "Description",
     value: "Lorem ipsum"
}]

getDataTablePropertyAsync(dataTableName, propertyName) → {Promise(DataTableProperty)}

Gets the value of a given property of the data table.

Parameters:
Name Type Description
dataTableName String

The name of the data table.

propertyName String

The name of the property.

Promise(DataTableProperty)
Example
spotfireDocument.getDataTablePropertiesAsync("My Data Table", "color").then(console.log);
// outputs something like
{
     name: "Color",
     value: {
         R: 100,
         G: 137,
         B: 250,
         A: 255,
         IsKnownColor: false,
         IsEmpty: false,
         IsNamedColor: false,
         IsSystemColor: false,
         Name: "ff6489fa"
     }
}

getDataTableRowsCountAsync(dataTableName) → {Promise(Number)}

Gets the row count for the specified data table.

Parameters:
Name Type Description
dataTableName String

The name of the data table.

Promise(Number)

getDataTablesNamesByIdsAsync() → {Promise(Object[])}

Gets the names and GUIDs of all data tables in the document.

An array of objects of the shape { name: String, id: String }.

Promise(Object[])
Example
spotfireDocument.getDataTablesNamesByIdsAsync().then(console.log)
// outputs something like
[{
     id: "2a2f783a-ad48-48b5-b93d-9af04d6618f7",
     name: "Table A"
}, {
     id: "be1b0c51-b086-4d28-b4c7-ee47ee82047b",
     name: "Table B"
}]

getDataTablesSaveSettingsAsync() → {Prommise(DataTableSaveSettings[])}

Gets the list of the "save settings" of all the data tables.

The list of the "save settings".

Prommise(DataTableSaveSettings[])

getLibraryContentAsync([parentId], [fullInformation]) → {Object}

Retrieves the content of a folder in the Spotfire Library.

Parameters:
Name Type Description
[ parentId ] String

GUID of the parent folder to read. If empty, content of home folder will be returned.

[ fullInformation ] Boolean

If true, the analysis and dataFunctions arrays will contain objects as {path, id}. If false (default), they will contain path as string.

  • The folder structure as {analysis: [], dataFunctions: [], subFolders: []}
Object

getMarkedRowsAsync([markingName], [dataTableName]) → {Promise(Object)}

Get the list of marked rows with content.

Parameters:
Name Type Default Description
[ markingName = active marking name ] String

The marking name that we want to get the marked rows.

[ dataTableName = active data table name ] String

The data table name that is marked.

  • An object which keys are the name of the columns and the values arrays of the selected values.
Promise(Object)
Example
spotfireDocument.getMarkedRowsAsync('MyMarking','aTable').then(function(markedRows) {
    alert(markedRows);
})

getMarkingsAsync() → {Promise(String[])}

Gets all marking names.

Promise(String[])

getMetadataAsync() → {Promise(Object)}

List the metadata of the document.

An object containing metadata of the document ('path', 'created', etc.).

Promise(Object)
Example
spotfireDocument.getMetadataAsync().then(console.log)
// Outputs something like
{
  contentSize: "139246",
  created: "02/11/2018 09:49:45",
  description: "",
  lastModified: "02/20/2020 16:07:00",
  path: "/Discngine (Connector 5.x)/Client Automation/empty",
  title: "empty"
}

getPropertiesAsync() → {Promise(Object[])}

Gets the value of all defined document properties.

An array of objects of the shape { name: String, value: String }.

Promise(Object[])
Example
spotfireDocument.getPropertiesAsync().then(console.log);
// Outputs something like
[
 {name: "Description", value: ""},
 {name: "Keywords", value: Array(0)},
 {name: "AllowWebPlayerResume", value: "False"},
 ...
]

getPropertyAsync(propertyName) → {Promise(String)}

Gets the value of a document property.

Parameters:
Name Type Description
propertyName String

The string value of the property.

Promise(String)
Example
spotfireDocument.getPropertiesAsync('PublicBookmarkCreation').then(console.log); // => "RequiresReadAndWriteAccess"

isDocumentOpen() → {Boolean}

True if a document is opened, false if not.

Boolean

markingExistsAsync(markingName) → {Promise(Boolean)}

Does the marking provided exist?

Parameters:
Name Type Description
markingName String

The name of the marking to check.

Promise(Boolean)

markRowsAsync(markingName, dataTableName, whereClause, operation) → {Promise}

Sets a marking in the analysis specified by the input parameters.

Parameters:
Name Type Default Description
markingName String

The marking name in which to set the marking.

dataTableName String

The data table in which to set the marking.

whereClause String

An expression string with conditions for the data columns used to set the marking. For more information, see the documentation for the TIBCO Spotfire® Expression Language.

operation = SpotfireDataSelectionOperations.replace SpotfireDataSelectionOperations  {Enum} 

The operation to use when combining this selection with previously set selections.

Enum options: replace, add, subtract, toggle, intersect
Promise
Example
spotfireDocument.markRowsAsync('MyMarking (0)','aTable','[Activity] <= 0', SpotfireDataSelectionOperations.add)

markRowsByIdsAsync(markingName, dataTableName, idColumnName, ids) → {Promise}

Mark rows identified by column and specified values for specified marking and data table.

Parameters:
Name Type Description
markingName String

The name of the marking in which you want to mark the rows.

dataTableName String

The name of the dataTable from where you want to mark rows.

idColumnName String

The name of the column that represents the id on which you want to select the rows.

ids Array.<String>

Array of ids that identified the rows to mark.

Promise
Example
spotfireDocument.markRowsByIdsAsync('MyMarking (1)', 'aTable', 'InChIKey', [
    'APZFVJKUDMXDFA-UHFFFAOYSA-N',
    'LQUMXBMVHBUSOC-UHFFFAOYSA-N',
    'KJTUBZKMFRILQD-UHFFFAOYSA-N',
    'WYCLKVQLVUQKNZ-UHFFFAOYSA-N'
])

onDataColumnsChanged(dataTableName, callback)

Adds a new callback to be executed when the list of data tables has changed.

Parameters:
Name Type Description
dataTableName String

The data table to watch.

callback onDataColumnsChangedCb

The callback to be executed when the list of Data Columns has changed.

onDataTablesChanged(callback)

Adds a new callback to be executed when the list of data tables has changed.

Parameters:
Name Type Description
callback onDataTablesChangedCb

The callback to be executed on closed changed event.

onDocumentChanged(callback) → {Number|Boolean}

Configures a callback that will be executed when a document has changed. Note that these callbacks can potentially be executed frequently.

Parameters:
Name Type Description
callback onDocumentChangedCb

The callback to be executed on document changed event.

The number of registered callback in case of success, false otherwise.

Number | Boolean

onDocumentClosed(callback)

Configures a callback that will be executed when a document is closed.

Parameters:
Name Type Description
callback onDocumentClosedCb

The callback to be executed on closed changed event.

onMarkingChanged(markingName, dataTableName, callback)

Configures the callback that will be called when a specific marking has changed for a specific data table. LIMITATION: in web player, all callbacks are called when a marking changes, regardless of whether it happens in the specified data table.

Parameters:
Name Type Description
markingName String

The marking to listen to.

dataTableName String

The datatable to listen to.

callback onMarkingChangedCb

The callback that will be executed when the marking changed for the corresponding data table.

openDocument(documentPath, [onDocumentOpenedHandler], [configurationBlockText], [location])

Opens an existing document from library or from a local file. In the Web Player, only files from library can be opened.

Parameters:
Name Type Default Description
documentPath String

The full path to the document in the library, or to a local drive if you are using only the TIBCO Spotfire ® Analyst client</>.

[ onDocumentOpenedHandler ] onDocumentOpenedEventHandler

The callback that will be executed after the document is opened.

[ err ] Error

The error that may have occurred or undefined.

[ configurationBlockText ] String

The configuration block text to be applied.

[ location = SpotfireDocumentLocation.library ] SpotfireDocumentLocation  {Enum} 

The location type of the document, from SpotfireDocumentLocation.

Enum options: library, local
Examples

Open a document from the library:

spotfireDocument.openDocument('/Discngine/Client Automation/empty')

Open a document from a local file:

spotfireDocument.openDocument('C:/temp/data.dxp', null, null, SpotfireDocumentLocation.local)

Open a document with a configuration block and a callback function:

spotfireDocument.openDocument('/MyTeam/data.dxp', function() {alert('document opened')}, 'myKey1="ATextToSave";myKey2=255;')

removeOnDataColumnsChanged(dataTableName, callback)

Removes a callback previously registered with the SpotfireDocument#onDataTablesChanged method.

Parameters:
Name Type Description
dataTableName String

The data table for which the callback was registered.

callback onDataColumnsChangedCb

The callback to unregister.

removeOnDataTablesChanged(callback)

Removes a callback previously registered with the SpotfireDocument#onDataTablesChanged method.

Parameters:
Name Type Description
callback onDataTablesChangedCb

The callback to unregister.

removeOnDocumentChanged(callback)

Removes a callback previously registered with the SpotfireDocument#onDocumentChanged method.

Parameters:
Name Type Description
callback onDocumentChangedCb

The callback to unregister.

removeOnDocumentClosed(callback)

Removes a callback previously registered with the SpotfireDocument#onDocumentClosed method.

Parameters:
Name Type Description
callback onDocumentClosedCb

The callback to unregister.

removeOnMarkingChanged(markingName, dataTableName, callback)

Removes a callback previously registered with the SpotfireDocument#onMarkingChanged method.

Parameters:
Name Type Description
markingName String

The marking for which the callback was registered.

dataTableName String

The data table for which the callback was registered.

callback onDataTablesChangedCb

The callback to unregister.

save(saveOptionsOrLibraryPath)

Saves the document.

Parameters:
Name Type Description
saveOptionsOrLibraryPath String | DocumentSaveOptions

List all options for saving the document. If array is string, assuming that the save operation is done in the library.

path String

The existing destination path of the document to be saved.

fileName String

The name of the document to be saved.

[ configurationBlockText ] String

The configuration block text that shall be embedded in the file when the document is saved.

[ location = SpotfireDocument.library ] SpotfireDocumentLocation  {Enum} 

The location where to save the document, from SpotfireDocumentLocation.

Enum options: library, local
[ libraryItemMetaData ] LibraryItemMetaData

The metadata to associate with the library item (not available if the document is saved locally).

[ description = '' ] String

the description

[ otherData ] Object

the list of all custom metadata you want to pull as metadata for the library document

Examples

Save the document as it is:

spotfireDocument.save()

Save the document as a new document in local folder (FOR ANALYST ONLY):

spotfireDocument.save({
    path:'c:\\TMP\\',
    fileName:'NewFileName.dxp',
    location: SpotfireDocumentLocation.local
})

Save the document as a new document in local folder (FOR ANALYST ONLY) with a configuration block:

spotfireDocument.save({
    path:'c:\\TMP\\',
    fileName:'NewFileName.dxp',
    location: SpotfireDocumentLocation.local,
    configurationBlockText: 'myKey1="ATextToSave";myKey2=255;'
})

Save the document as a new document in library:

 spotfireDocument.save({
     path:'/myLibraryFolder/',
     fileName:'NewFileName'
})

Save the document as a new document in library with configurationBlockText:

spotfireDocument.save({
    path:'/myLibraryFolder/',
    fileName:'NewFileName',
    configurationBlockText: 'myKey1="ATextToSave";myKey2=255;'
})

saveTemplateAsync(saveParameters) → {Promise}

Saves the document as a template.
A template is a document with empty data tables. During the process, the data tables are temporarily exported into SBDF files of the same name and with the extension '.export.sbdf', in the same place as the template. We therefore advise you to make sure that no SBDF files with these names are present in the location of the future template, otherwise they will be deleted.

Parameters:
Name Type Description
saveParameters DocumentSaveOptions

Describes the parameters needed to save the template.

path String

The existing destination path of the document to be saved.

fileName String

The name of the document to be saved.

[ configurationBlockText ] String

The configuration block text that shall be embedded in the file when the document is saved.

[ location = SpotfireDocument.library ] SpotfireDocumentLocation  {Enum} 

The location where to save the document, from SpotfireDocumentLocation.

Enum options: library, local
[ libraryItemMetaData ] LibraryItemMetaData

The metadata to associate with the library item (not available if the document is saved locally).

[ description = '' ] String

the description

[ otherData ] Object

the list of all custom metadata you want to pull as metadata for the library document

Promise
Examples

Save a template in the library:

spotfireDocument.saveTemplateAsync({
    path: '/Discngine/Client Automation',
    fileName: 'myNewTemplate',
    configurationBlockText: 'myKey1="ATextToSave";myKey2=255;'
})

Save a template in an existing local folder:

spotfireDocument.saveTemplateAsync({
    path: 'C:/temp',
    fileName: 'myNewTemplate',
    location: 'Local'
})

setSpinnerState(isActive, message, [timeout]) → {this}

Allows to add a spinner containing a custom message to indicate when Spotfire is working. This can be convenient to prevent multiple blinking caused by Python scripts being executed sequentially. Calling the method multiple times while changing message allows to update the message displayed to the user.

Parameters:
Name Type Default Description
isActive Boolean

Whether to show or hide the spinner.

message String

The message you want to display on the screen.

[ timeout = 10000 ] Number

The time in ms after which the spinner will be unset automatically. You can disable it by explicitely passing 0.

Returned with this to allow chaining.

this

subscribeToDocumentEvents()

Subscribes the mandatory handlers to document event (closed and changed). Will be recall on document changed.