Initializing help system before first use

Accessing Array Data

There are several ways to access the data from an InsightArray object.

If you have access to the associated sets you can build up the possible keys for the array using these and iterate over each, calling InsightArray#getValue on each. However, this is very inefficient in most cases as the set data needs to be downloaded separately. The key information is already available in the InsightArray object and you can use one of the follow methods instead.

You can get an iterator for the array and loop through that:
// Using an array iterator
view.withFirstScenario()
   .withEntities('Population')
   .notify(function(scenario) {
       var population = scenario.getArray('Population');
       var iterator = population.getIterator();
       var item;
       while(item = iterator.next()) {
           // item will contain {key: ['UK'], value: 64000000}
       }
   })
   .start();
It is also possible to get a list of all the populated keys for an InsightArray:
var population = scenario.getArray('Population');
var keys = population.getKeys();
// keys will contain an array of composite keys
Finally, it is possible to get a JavaScript array listing all entries of the InsightArray, both keys and values:
var population = scenario.getArray('Population');
var keyValues = population.toObjectArray();
// keyValues will contain be an array of key-value objects
keyValues.forEach(function(entry) {
   // entry.key will be ['UK']
   // entry.value will be 64000000
});

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