Initializing help system before first use

ScenarioObserver

Provides a way to register for data and state changes for scenarios and entities.

Method summary

name description
bindAutoForm Bind an AutoForm DOM element that matches the formId property in the options argument.
bindAutoTable Bind AutoTable configuration to a specified DOM table element and update the AutoTable whenever there are data changes.
bindAutoText Bind AutoText elements from the DOM that match the selector property in the options argument.
bindImageAttachments Bind IMG elements marked with the 'data-attachment-filename' attribute, to display image attachments in the page.
dispose This stops the event listener for the configured scenarios and entities.
filter Apply a filter to an entity.
isDisposed Check if the scenario observer is disposed.
notify Add a function to be called with the requested data whenever there are changes to that data.
once Add a function to be called once with the requested data and then dispose this observer.
start This tells the system to go and fetch the configured scenarios and entities and return their values. Also it starts listening for change events on those scenarios and entities.
withAttachments Registers this observer to be notified whenever the scenario attachments change.
withEntities Specify the entities this scenario observer is interested in.
withSummaryData Registers this observer to be notified whenever the scenario summary data changes.
withViewProperties Specify the view properties this scenario observer is interested in.

Methods

method
bindAutoForm ( options ) → {ScenarioObserver}

Bind an AutoForm DOM element that matches the formId property in the options argument.

Parameters:
params
Name Type Description
options
type
ScenarioObserver~BindAutoFormOptions
AutoForm binding options
details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top
method
bindAutoTable ( options ) → {ScenarioObserver}

Bind an AutoTable DOM element that matches the tableId property in the options argument. The options and overrides objects passed in should match the AutoTable constructor arguments except where it is expecting Scenario objects you can pass scenario id and they will get resolved.

Parameters:
params
Name Type Description
options
type
ScenarioObserver~BindAutoTableOptions
AutoTable binding options
details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top
method
bindAutoText ( options ) → {ScenarioObserver}

Bind AutoText elements from the DOM that match the selector property in the options argument. Alternatively, if a string arguments is passed in the this acts as the selector.

Parameters:
params
Name Type Description
options
type
ScenarioObserver~BindAutoTextOptions | string
AutoText binding options object or the the selector is a string
details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top
method
bindImageAttachments ( options ) → {ScenarioObserver}

Bind IMG elements marked with the 'data-attachment-filename' attribute, to display image attachments in the page.

Parameters:
params
Name Type Description
options
type
ScenarioObserver~BindImageAttachmentOptions | jQuery | string
an image attachment binding options object, a jQuery selector or a CSS selector string
details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top
method
dispose ( )

This stops the event listener for the configured scenarios and entities. The notify callback or bound auto components related to this scenario observer will not receive any further updates.

details
Back to Top
method
filter ( entity, callback ) → {ScenarioObserver}

Apply a filter to an entity.

Parameters:
params
Name Type Description
entity
type
string
the entity name to filter on
callback
type
ScenarioObserver~FilterCallback
the filter to apply
details
Returns:
returns table
Type Description
type
ScenarioObserver
Example
examples
insight.getView()
    .withFirstScenario()
    .withViewProperties('selectedDay')
    .withEntities('SUPPLY')
    .filter('SUPPLY', function (viewProperties) {
        // Array filter: filters the 'DAY' index of the array by the value of a view property called
        // 'selectedDay' and filters the 'REGION' index of the array by hard-coded values.
        return {
            'DAY': [viewProperties.get('selectedDay')],
            'REGION': ['SOUTH', 'WEST']
        }
    })
    .notify(function (scenario) {})
    .start();
Back to Top
method
isDisposed ( ) → {boolean}

Check if the scenario observer is disposed.

details
Returns:
returns table
Type Description
type
boolean
Whether this scenario observer is disposed
Back to Top
method
notify ( callback ) → {ScenarioObserver}

Add a function to be called when there are data changes, depending on what has been subscribed to.

Parameters:
params
Name Type Description
callback
type
NotifyCallback
the callback to invoke
details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top
method
once ( callback ) → {ScenarioObserver}

Add a function to be called once with the requested data and then dispose this observer. once() and notify() are mutually exclusive.

Parameters:
params
Name Type Description
callback
type
NotifyCallback
the callback to invoke
details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top
method
start ( ) → {ScenarioObserver}

This tells the system to go and fetch the configured scenarios and entities and return their values. Also it starts listening for change events on those scenarios and entities.

details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top
method
withAttachments ( options ) → {ScenarioObserver}

Registers this observer to be notified whenever the scenario or app attachments change.

The argument to this function can be one of the following:
  • An array of tags to observe.
  • A single tag to observe.
  • A configuration object (of type WithAttachmentsOptions) indicating which tags to observe and whether to observe scenario or app attachments.

Parameters:
params
Name Type Description
options
type
ScenarioObserver~WithAttachmentsOptions
details
Returns:
returns table
Type Description
type
ScenarioObserver
Example
examples
insight.ready(function () {
     var view = insight.getView();
     view
             .withFirstScenario()
             .withAttachments({tags: ['tagA', 'tagB'], app: true, scenario: true})
             .notify(function (scenario) {
                 // code to access attachments here...
             });
            });
Back to Top
method
withEntities ( entities ) → {ScenarioObserver}

Specify the entities this scenario observer is interested in.

Parameters:
params
Name Type Description
entities
type
string | Array.<string>
the entities to observe
details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top
method
withSummaryData ( ) → {ScenarioObserver}

Registers this observer to be notified whenever the scenario summary changes. Can be used in combination with ScenarioObserver#withEntities to get notified when either the summary data or entity data change.

details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top
method
withViewProperties ( viewProperties ) → {ScenarioObserver}

Specify the view properties this scenario observer is interested in.

Parameters:
params
Name Type Description
viewProperties
type
string | Array.<string>
the view properties to observe
details
Returns:
returns table
Type Description
type
ScenarioObserver
Back to Top

Type Definitions

members
BindAutoFormOptions - {
type
object }
details
Properties:
properties
Name Type Argument Description
formId
type
string
id of the DOM element to bind to
scenario
type
string | number
optional  the scenario id or index to use, defaults to the first scenario in the selection
loadButton
type
string
optional  id of the DOM element to bind the load action to
runButton
type
string
optional  id of the DOM element to bind the run action to
saveButton
type
string
optional  id of the DOM element to bind the save action to
cancelButton
type
string
optional  id of the DOM element to bind the cancel action to
additionalBindings
type
object
optional  additional binding information passed in to the AutoForm. See the AutoForm#bindForm inputs argument
method
BindAutoTableError ( error )
Parameters:
params
Name Type Description
error
type
Error
The error encountered
details
Back to Top
members
BindAutoTableOptions - {
type
object }
details
Properties:
properties
Name Type Argument Default Description
tableId
type
string
id of the DOM table element to bind to
scenario
type
string | number
optional  scenario id or index to use, defaults to the first scenario in the selection
columnOptions
type
Array.<AutoTable~ColumnOptions>
optional  list of column options for AutoTable. The scenario properties on columns can be specified as a scenario index or id and they will automatically be transposed into Scenario objects
indicesOptions
type
Object.<string, (AutoTable~IndicesOptions|Array.<AutoTable~IndicesOptions>)>
optional  map of indices options for AutoTable
overrides
type
object
optional  map of DataTables overrides for AutoTable
addRemoveRow
type
boolean
optional  false enable the add/remove row functionality. See the AutoTable constructor
onError
type
ScenarioObserver~BindAutoTableError
optional  Callback if Autotable creation leads to error
members
BindAutoTextOptions - {
type
object }
details
Properties:
properties
Name Type Argument Description
selector
type
string
a jQuery selector defining the DOM elements to bind to
scenario
type
string | number
optional  the scenario id or index to use, defaults to the first scenario in the selection
members
BindImageAttachmentOptions - {
type
object }
details
Properties:
properties
Name Type Description
selector
type
string
a jQuery selector or CSS selector string defining the IMG elements to bind to within the DOM
method
FilterCallback ( viewProperties ) → {Object.<(string|number), *>}

Filter callback to apply to the entity.

At times it is desirable to only retrieve a slice of an array, i.e. only retrieve the elements for a subset of the array's index values. This callback should return an object containing an array of values to use for each index set. If the index set is not included in the object then all values in the index set are used. The index set can either be specified by name or by ordinal. (The first index set of the array has ordinal 0.)

Parameters:
params
Name Type Description
viewProperties
type
MaskedViewProperties
Only allows access to the view properties that this scenario observer is listening to
details
Returns:
returns table
Type Description
type
Object.<(string|number), *>
the filter; a map from index set name (or ordinal) to array of filter values
Example
examples
// Array filter: filters the second index of the array by the value of a view property called 'selectedDay'
function (viewProperties) {
    return {
        1: [viewProperties.get('selectedDay')]
    }
}

// Array filter: filters the 'DAY' index of the array by the value of a view property called 'selectedDay' and
// filters the 'REGION' index of the array by hard-coded values.
function (viewProperties) {
    return {
        'DAY': [viewProperties.get('selectedDay')],
        'REGION': ['SOUTH', 'WEST']
    }
}
Back to Top
members
ScenarioObserverOptions - {
type
object }
details
Properties:
properties
Name Type Argument Description
disposeCallback
type
function
optional  to be called when the observer is disposed
startCallback
type
function
optional  to be called when the observer is started
members
WithAttachmentsOptions - {
type
object }
details
Properties:
properties
Name Type Argument Default Description
tags
type
string | Array.<string>
optional  List of tags to observe (if not provided, all attachments will be observed)
filenames
type
string | Array.<string>
optional  List of filenames to observe (if not provided, all attachments will be observed)
scenario
type
boolean
optional  true Whether to notify the callback when scenario attachments are changed
app
type
boolean
optional  true Whether to notify the callback when app attachments are changed
project
type
boolean
optional  true Deprecated since Js Api 4.5. Use app property instead ScenarioObserver#withAttachments argument

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