View
Method summary
name | description |
---|---|
addScenarioToShelf | Adds a scenario to the shelf specified by its ID and optionally pos index (0 based) |
addUnloadHandler | Register a view unload handler. |
clearShelf | Clears the shelf of all its scenarios |
configure | Set global configuration options for the view. |
createAppAttachment | Create a new app attachment. |
createProjectAttachment | Use View#createAppAttachment instead. |
createScenarioAttachment | Create a new scenario attachment. |
executeScenario | Executes the scenario specified by its ID |
getApp | The Insight app associated with this View. |
getAppId | The ID of the Insight app associated with this View. |
getConfiguration | Get the entire view configuration or a single configuration option if a key is provided. |
getProject | Use View#getApp instead. |
getProjectId | Use View#getAppId instead. |
getScenarioCount | Gets the number of scenarios in the selection. |
getScenarioIndex | Returns the index of a scenario by id. If the id is a number, or validly represents one as a string, it will be treated as an index, and returned as a number if the index is valid. |
getScenarioProperties | Gets the properties of a scenario. |
getUser | The current User. |
getViewProperty | Gets a view property by name. |
hasSingleScenario | Indicates whether this View represents a single selected scenario. |
isDebugEnabled | Indicates whether the view is running in debug mode. |
isModified | Indicates whether there are pending changes in this View. |
isReadOnly | Indicates whether this view is read only. |
modifyScenario | Start a scenario modification. |
openAppAttachmentsDialog | Opens the app attachments dialog. |
openProjectAttachmentsDialog | Use View#openAppAttachmentsDialog instead. |
openScenarioAttachmentsDialog | Opens the scenario attachments dialog. |
promptToClearInputData | |
reload | Reloads the view. |
removeScenarioFromShelf | Removes a scenario to the shelf specified by its ID |
removeUnloadHandler | Remove a registered view unload handler. |
replaceSelection | Replace the scenario selection for the view. Specify a list of scenarios (or a Promise that resolves to a list of scenarios) that can be used by the view. This will result in the user-selected scenarios that appear on the shelf being ignored. |
save | Save all changes made within this View. |
setShelf | Sets the shelf to contain the array of scenario's specified in the array |
setViewProperties | Sets multiple view properties in a single operation. |
setViewProperty | Sets a view property. |
showErrorMessage | Show an error message in the webclient |
showInfoMessage | Show an information message in the webclient |
start | Start ScenarioObservers and add no-results and execution overlays to the view. |
uploadAppAttachment | Opens the app attachments dialog in a mode where any file uploaded will be automatically tagged with the given tag. |
uploadProjectAttachment | Use View#uploadAppAttachment instead. |
uploadScenarioAttachment | Opens the scenario attachments dialog in a mode where any file uploaded will be automatically tagged with the given tag. |
withAllScenarios | Create a new ScenarioObserver that listens to all scenarios in the view selection. |
withFirstScenario | Create a new ScenarioObserver that listens to the first scenario in the view selection. |
withScenarios | Listen to a list of scenarios. |
Methods
- addScenarioToShelf ( scenarioId, index ) → {void}
-
Adds a scenario to the shelf specified by its ID and optionally pos index (0 based)
Parameters:
paramsName Type Argument Description scenarioId typeStringthe scenario to add index typeIntegeroptional add the scenario to this position on the shelf detailsReturns:returns tableType Description typevoidExample
examples
Back to Top// adds the scenario matching the ID to the end of the shelf view.addScenarioToShelf('5cc7bf0a-cc46-414a-99fc-ff40c8bd53f7') // adds the scenario matching the ID to index position 1 view.addScenarioToShelf('5cc7bf0a-cc46-414a-99fc-ff40c8bd53f7', 1)
- addUnloadHandler ( callback ) → {number}
-
Register a view unload handler.
Parameters:
paramsName Type Description callback typeView~UnloadHandlerCalled before the view is unloaded detailsReturns:returns tableType Description typenumberThe unload handler id - clearShelf ( ) → {void}
-
Clears the shelf of all its scenarios
detailsReturns:returns tableType Description typevoidExample
examples
Back to Top// clears all of the scenarios from the shelf view.clearShelf()
- configure ( options ) → {View}
-
Set global configuration options for the view.
Parameters:
paramsName Type Description options typeView~ViewConfigurationView configuration options detailsReturns:returns tableType Description typeViewThe instance of the view Example
examples
Back to Topvar view = insight.getView(); view.configure({ messageOffset: 50, noResultsMessage: 'There are no results.' });
- createAppAttachment ( options ) → {Promise}
-
Create a new app attachment.
Parameters:
paramsName Type Description options typeNewAttachmentOptionsThe new attachment options detailsReturns:returns tableType Description typePromiseResolves when user closes the editor or if attachment create fails Example
examples
Back to Topview.createAppAttachment({filename: 'my_file.xml', tag: 'atag'}) .then(function(data) { console.log(data.attachment); });
- createProjectAttachment ( )
-
Use View#createAppAttachment instead.
details- Deprecated since Js Api 4.5
- createScenarioAttachment ( options, indexOrId ) → {Promise}
-
Create a new scenario attachment.
Parameters:
paramsName Type Argument Default Description options typeNewAttachmentOptionsThe new attachment options indexOrId typenumber | stringoptional 0 The scenario index on shelf or scenario id detailsReturns:returns tableType Description typePromiseResolves when user closes the editor or if attachment create fails Example
examples
Back to Top// Create attachment for seconf scenario on the shelf (index = 1). view.createScenarioAttachment({filename: 'my_file.xml', tag: 'atag'}, 1) .then(function(data) { console.log(data.attachment); });
- executeScenario ( scenarioId, executionMode, options ) → {Promise}
-
Executes the scenario specified by its ID
Parameters:
paramsName Type Argument Default Description scenarioId typestringThe scenario ID to execute executionMode typestringoptional insight.enums.ExecutionType.RUN the mode of execution to perform options typeObjectoptional execution options Properties
paramsName Type Argument Description suppressClearPrompt typebooleanoptional whether, on using an execution mode that clears input data, to suppress the confirmation prompt detailsReturns:returns tableType Description typePromisepromise, resolves when the scenario is successfully queued for execution Example
examples
Back to Topvar runPromise = view.executeScenario('58c7d13d-8467-49c7-b3b0-f549478b30f7', "RUNFAST"); runPromise .then(function () { // scenario has been queued for execution }) .catch(function (err) { // scenario could not be executed. });
- getApp ( ) → {App}
-
The Insight app associated with this View.
detailsReturns:returns tableType Description typeAppthe app associated with the view Example
examples
Back to Topvar view = insight.getView(); view.getApp();
- getAppId ( ) → {string}
-
The ID of the Insight app associated with this View.
detailsReturns:returns tableType Description typestringthe ID of the app associated with the view Example
examples
Back to Topvar view = insight.getView(); view.getAppId();
- getConfiguration ( key ) → {string|undefined|View~ViewConfiguration}
-
Get the entire view configuration or a single configuration option if a key is provided.
Parameters:
paramsName Type Argument Description key typestringoptional configuration key to fetch detailsReturns:returns tableType Description typestring | undefined | View~ViewConfigurationwhole configuration object or, if key is specified, a single configuration value. Returns undefined if key does not exist. Example
examples
Back to Topinsight.getView().getConfiguration('notLoadedMessage'); // returns 'scenario not loaded' by default.
- getProject ( )
-
Use View#getApp instead.
details- Deprecated since Js Api 4.5
- getProjectId ( )
-
Use View#getAppId instead.
details- Deprecated since Js Api 4.5
- getScenarioCount ( ) → {number}
-
Gets the number of scenarios in the selection.
detailsReturns:returns tableType Description typenumberthe number of scenarios in the selection Example
examples
Back to Topvar view = insight.getView(); view.getScenarioCount();
- getScenarioIndex ( id ) → {number}
-
Returns the index of a scenario by id.
If the id is a number, or validly represents one as a string, it will be treated as an index, and returned as a number if the index is valid.
Parameters:
paramsName Type Description id typenumber | stringThe id or index to look up detailsReturns:returns tableType Description typenumberthe index of scenario, or -1 if not found - getScenarioProperties ( index ) → {Promise.<ScenarioProperties>}
-
Gets the properties of a scenario.
Parameters:
paramsName Type Argument Default Description index typenumberoptional 0 The index of the scenario from the selection. Indexed from 0. Defaults to the first scenario. detailsThrows:
exceptionsIf the scenario index is out of bounds- Type
-
typeError
Returns:returns tableType Description typePromise.<ScenarioProperties>Resolves once the scenario has been fetched from the server. Rejected with an error object if an error is encountered whilst fetching the data. Example
examples
Back to Topvar view = insight.getView(); var propsPromise = view.getScenarioProperties(0); // zero is first scenario propsPromise .then(function (props) { var scenarioName = props.getName(); });
- getUser ( ) → {Promise.<User>}
-
The current User.
detailsReturns:returns tableType Description typePromise.<User>User object within the promise response Example
examples
Back to Topvar view = insight.getView(); var userPromise = view.getUser(); userPromise .then(function(user) { // user is available at this point. });
- getViewProperty ( name ) → {*}
-
Gets a view property by name.
Parameters:
paramsName Type Description name typestringthe name of the view property detailsThrows:
exceptionsError if the view property has not been setReturns:returns tableType Description type*the value of the view property Example
examples
Back to Topvar view = insight.getView(); view.getViewProperty('Custom Property');
- hasSingleScenario ( ) → {boolean}
-
Indicates whether this View represents a single selected scenario.
detailsReturns:returns tableType Description typebooleantrue if this View contains a single selection and that selection is a scenario, otherwise false Example
examples
Back to Topvar view = insight.getView(); if (view.hasSingleScenario() { // this code is only for single scenarios. }
- isDebugEnabled ( ) → {View.isDebugEnabled|Insight.isDebugEnabled|boolean|*}
-
Indicates whether the view is running in debug mode.
detailsReturns:returns tableType Description typeView.isDebugEnabled | Insight.isDebugEnabled | boolean | *Example
examples
Back to Topinsight.getView().isDebugEnabled();
- isModified ( )
-
Indicates whether there are pending changes in this View.
detailsReturns:returns tableType Description True if changes are pending, otherwise false Example
examples
Back to Topinsight.getView().isModified();
- isReadOnly ( ) → {boolean}
-
Indicates whether this view is read only.
detailsReturns:returns tableType Description typebooleantrue if the view is read only, false if not Example
examples
Back to Topinsight.getView().isReadOnly();
- modifyScenario ( index ) → {ScenarioDataChange}
-
Start a scenario modification.
Parameters:
paramsName Type Argument Default Description index typenumberoptional 0 The index of the scenario from the selection. Indexed from 0. Defaults to the first scenario. detailsThrows:
exceptionsIf the scenario index is out of bounds- Type
-
typeError
Returns:returns tableType Description typeScenarioDataChangeThe scenario modification object on which to commit changes Example
examples
Back to Topvar view = insight.getView(); var modifyPromise = view.modifyScenario(0) // modify first scenario. .setScalar('numAccounts', 15000) .commit(); modifyPromise .then(function() { // data change saved }).catch(function(err) { // failed to save data change });
- openAppAttachmentsDialog ( message )
-
Opens the app attachments dialog.
A custom message can shown within the dialog in order to guide the user in what they are expected to achieve using the dialog (e.g., uploading a particular type of attachment, adding a tag, etc.)
Parameters:
paramsName Type Argument Description message typestringoptional A custom message to show within the dialog detailsExample
examples
Back to Topinsight.getView().openAppAttachmentsDialog('Upload an attachment');
- openProjectAttachmentsDialog ( )
-
Use View#openAppAttachmentsDialog instead.
details- Deprecated since Js Api 4.5
- openScenarioAttachmentsDialog ( message, indexOrId )
-
Opens the scenario attachments dialog.
A custom message can shown within the dialog in order to guide the user in what they are expected to achieve using the dialog (e.g., uploading a particular type of attachment, adding a tag, etc.)
By default, the attachments of the first scenario on the shelf will be shown in the dialog. An alternative scenario can be specified using either its id or its selection index.
Parameters:
paramsName Type Argument Default Description message typestringoptional A custom message to show within the dialog indexOrId typestring | numberoptional 0 The index or id of the scenario whose attachments to show in the dialog detailsExample
examples
Back to Topinsight.getView().openScenarioAttachmentsDialog('Upload an attachment'); // First scenario on the shelf insight.getView().openScenarioAttachmentsDialog('Upload an attachment', 1); // Second scenario on the shelf insight.getView().openScenarioAttachmentsDialog('Upload an attachment', scenario.getId());
- promptToClearInputData ( scenarioId, options ) → {Promise.<boolean>}
-
Parameters:
paramsName Type Argument Description scenarioId typestringoptions typeObjectoptional Properties
paramsName Type Argument Description force typebooleanoptional Whether to force the prompt to appear even if not normally merited executionMode typestringoptional The name of the execution mode to be used detailsReturns:returns tableType Description typePromise.<boolean>A promise that resolves to whether the load should proceed - reload ( ) → {boolean}
-
Reloads the view.
detailsReturns:returns tableType Description typebooleantrue if the view has been reloaded, false if not Example
examples
Back to Topif (insight.getView().reload()) { // view was reloaded }
- removeScenarioFromShelf ( scenarioId ) → {void}
-
Removes a scenario to the shelf specified by its ID
Parameters:
paramsName Type Description scenarioId typeStringthe scenario to remove detailsReturns:returns tableType Description typevoidExample
examples
Back to Top// removes the scenario matching the ID from the shelf view.removeScenarioToShelf('5cc7bf0a-cc46-414a-99fc-ff40c8bd53f7')
- removeUnloadHandler ( id )
-
Remove a registered view unload handler.
Parameters:
paramsName Type Description id typenumberThe handler id given when registered details - replaceSelection ( ) → {Promise.<Array.<string>>}
-
Replace the scenario selection for the view. Specify a list of scenarios (or a Promise that resolves to a list of scenarios) that can be used by the view. This will result in the user-selected scenarios that appear on the shelf being ignored.
detailsReturns:returns tableType Description typePromise.<Array.<string>>Resolves with a list of scenario ids if successfully applied the new selection. Rejected with an Error if failed to apply new selection Example
examples
Back to Topfunction getSomeScenarioIds() { return new Promise(function (resolve, reject) { $.get(document.location.origin + '/insightservices/rest/v1/data/project/' + insight.getView().getApp().getId() + '/children?maxResults=9999', function (result) { var ids = result.items .filter(function (item) { return item.objectType === 'SCENARIO'; }) .map(function (item) { return item.id; }); resolve(ids); }); }); } insight.getView().replaceSelection(getSomeScenarioIds()) .then(function (selection) { console.log('Successfully applied the replacement selection', selection); });
- save ( ) → {Promise.<undefined>}
-
Save all changes made within this View.
detailsReturns:returns tableType Description typePromise.<undefined>Resolves when the view is saved successfully Example
examples
Back to Topvar view = insight.getView(); var savePromise = view.save(); savePromise .then(function () { // view was saved }).catch(function (err) { // view was not able to save });
- setShelf ( scenarios ) → {void}
-
Sets the shelf to contain the array of scenario's specified in the array
Parameters:
paramsName Type Description scenarios typeArrayscenario ID's as an array detailsReturns:returns tableType Description typevoidExample
examples
Back to Top// sets the state of the shelf to contain only the scenarios specified view.setShelf(['5cc7bf0a-cc46-414a-99fc-ff40c8bd53f7', '5cc7bf0a-cc46-3454-99fc-ff40c8bd5444'])
- setViewProperties ( properties )
-
Sets multiple view properties in a single operation.
Parameters:
paramsName Type Description properties typeObject.<string, *>the name value pairs of properties to set detailsExample
examples
Back to Topvar view = insight.getView(); view.setViewProperties({ propertyNumber: 1888, propertyName: 'Leap Year' });
- setViewProperty ( name, value )
-
Sets a view property.
Parameters:
paramsName Type Description name typestringthe name of the property value type*the value of the property detailsExample
examples
Back to Topvar view = insight.getView(); view.setViewProperty('Custom Property', 999);
- showErrorMessage ( message ) → {void}
-
Show an error message in the webclient
Parameters:
paramsName Type Description message typestringThe message to show detailsReturns:returns tableType Description typevoidExample
examples
Back to Topview.showErrorMessage('An error has occurred and your request could not be completed');
- showInfoMessage ( message ) → {void}
-
Show an information message in the webclient
Parameters:
paramsName Type Description message typestringThe message to show detailsReturns:returns tableType Description typevoidExample
examples
Back to Topview.showInfoMessage('Action completed successfully');
- start ( ) → {Promise.<View>}
-
Start ScenarioObservers and add no-results and execution overlays to the view.
detailsReturns:returns tableType Description typePromise.<View>for chaining Example
examples
Back to Topvar view = insight.getView(); view.start();
- uploadAppAttachment ( tagName, message ) → {Promise.<undefined>}
-
Opens the app attachments dialog in a mode where any file uploaded will be automatically tagged with the given tag.
Parameters:
paramsName Type Description tagName typestringthe tag to assign when uploading message typestringoptional custom message to show in the upload dialog detailsReturns:returns tableType Description typePromise.<undefined>Resolves when the dialog is opened successfully Example
examples
Back to Topview.uploadAppAttachment('input-sheet', 'Custom message', 0);
- uploadProjectAttachment ( )
-
Use View#uploadAppAttachment instead.
details- Deprecated since Js Api 4.5
- uploadScenarioAttachment ( tagName, message, indexOrId ) → {Promise.<undefined>}
-
Opens the scenario attachments dialog in a mode where any file uploaded will be automatically tagged with the given tag.
Parameters:
paramsName Type Argument Default Description tagName typestringThe tag to assign when uploading message typestringoptional Custom message to show in the upload dialog indexOrId typeinteger | stringoptional 0 Scenario selection index or scenario id detailsReturns:returns tableType Description typePromise.<undefined>Resolves when the dialog is opened successfully Example
examples
Back to Topview.uploadScenarioAttachment('input-sheet', 'Custom message', 0);
- withAllScenarios ( ) → {ScenarioObserver}
-
Create a new ScenarioObserver that listens to all scenarios in the view selection.
detailsReturns:returns tableType Description typeScenarioObserverExample
examples
Back to Topinsight.getView() .withAllScenarios() .withEntities('ENTITY_NAME') .notify(myNotifyFunc); // notify callback for entity data updates.
- withFirstScenario ( ) → {ScenarioObserver}
-
Create a new ScenarioObserver that listens to the first scenario in the view selection.
detailsReturns:returns tableType Description typeScenarioObserverExample
examples
Back to Topinsight.getView() .withFirstScenarios() .withEntities('ENTITY_NAME') .notify(myNotifyFunc); // notify callback for entity data updates.
- withScenarios ( arguments ) → {ScenarioObserver}
-
Create a new ScenarioObserver that listens to list of scenarios from the view selection. Provide either a number, list of numbers or an array of numbers, or the scenario ids.
Parameters:
paramsName Type Description arguments typenumber | string | Array.<number> | Array.<string>the selection indices or scenario ids detailsReturns:returns tableType Description typeScenarioObserverExample
examples
Back to Topinsight.getView() .withScenarios(0, 2) // observes the first and third scenarios .withEntities('ENTITY_NAME') .notify(myNotifyFunc); // notify callback for entity data updates.
Type Definitions
- UnloadHandler ( ) → {Promise}
-
Called before the view is unloaded, giving your custom code chance to save or cleanup.
detailsReturns:returns tableType Description typePromiseResolves or rejects when view shutdown tasks have been completed. -
ViewConfiguration - {
typeobject }
-
View configuration data structure.details
Properties:
propertiesName Type Argument Default Description messageOffset typenumberoptional 0 The vertical offset for user messages whilst this view is displayed. noResultsOverlay typebooleanoptional true Whether to make use of the 'no results' overlay. noResultsMessage typestringoptional 'no results available' The message displayed in the 'no results' overlay. notLoadedOverlay typebooleanoptional true Whether to enable the scenario not loaded overlays notLoadedMessage typestringoptional 'scenario not loaded' The message to display in the scenario not loaded overlays executionOverlay typebooleanoptional true Whether to make use of the 'execution' overlay. executionOverlayMessage typestringoptional 'Please wait...' The message displayed in the 'execution' overlay. Example
examplesvar view = insight.getView(); view.configure({ messageOffset: 50, notLoadedOverlay: false, executionOverlayMessage: 'Scenario running..' });
© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.