mapSummary.keys
Property Description |
Holds the keys that were passed to the map stage by the getInputData stage. Note that keys are sorted in the following way:
|
Type |
iterator |
Since |
2015.2 |
Members
Member |
Type |
Required/Optional |
Description |
---|---|---|---|
iterator().each(parameters) |
function |
required |
Executes one time for each key. |
parameters
Member |
Type |
Required/Optional |
Description |
---|---|---|---|
iteratorFunction(key, executionCount, completionState) See also functionParameters. |
function |
required |
Provides logic to be executed during each iteration. |
functionParameters
Parameter |
Type |
Required/Optional |
Description |
---|---|---|---|
key |
string |
optional |
Represents a key that was passed to the map stage. |
executionCount |
number |
optional |
The number of times the map function was called for the key. |
completionState |
string |
optional |
A setting that indicates whether the map function was executed successfully for the key. Possible values are ‘COMPLETE’, ‘FAILED’, and ‘PENDING.’ The system uses 'PENDING' if the script left the stage before it tried to process the key. This behavior can occur when exitOnError is set to true. |
Syntax
The following snippets show three ways you could use this iterator.
This code isn't a functional example. For a complete script example, see SuiteScript 2.x Map/Reduce Script Code Samples.
//Add additional code.
...
// Log all keys from the map stage.
var mapKeys = [];
summary.mapSummary.keys.iterator().each(function (key){
mapKeys.push(key);
return true;
});
log.debug({
title: 'Map stage keys',
details: mapKeys
});
// Create a log entry showing whether the map function was executed succesfully for each key.
summary.mapSummary.keys.iterator().each(function (key, executionCount, completionState){
log.debug({
title: 'Map key ' + key,
details: 'Outcome for map key ' + key + ': ' + completionState + ' // Number of attempts used: ' + executionCount
});
return true;
});
// Create a log entry showing the total number of keys for which the map function executed successfully.
var mapKeysProcessed = 0;
summary.mapSummary.keys.iterator().each(function (key, executionCount, completionState){
if (completionState === 'COMPLETE'){
mapKeysProcessed++;
}
return true;
});
log.debug({
title: 'Map key statistics',
details: 'Total number of map keys processed successfully: ' + mapKeysProcessed
});