Initializing help system before first use

Accessing Set Entities

Set entities are treated as one-dimensional arrays, each element being an object with a value and a label property.

You can access the elements of a set with the square bracket [ ] notation. Set entities are simple arrays and it is very common to iterate over them.

View Designer

Code editor
<vdl version="4.7">
    <vdl-page>
        <vdl-section heading="Accessing set entities">
            <vdl-row>
                <vdl-column vdl-repeat="=item in scenario.entities.RISK">
                  <span vdl-text="=item.value"></span>
                </vdl-column>
            </vdl-row>
        </vdl-section>
    </vdl-page>
</vdl>
renders as:

A Rendered View of a Set Entity

Rendered View of a Set Entity

For more on loops and the <vdl-repeat> element, see Using Loops with Arrays and Sets.

If you wish to extract individual elements from a set entity, you need to protect the statement with a guard:

<span vdl-text="=scenario.entities.RISK.length && scenario.entities.RISK[0].value ?
scenario.entities.RISK[0].value :
'' ">
</span>
By default, there is no guarantee about the order in which members of a set entity will be returned. However, within a <script> block, a set sorter function can be assigned via the JavaScript API.
<script>
function setSorter(originalSet) { 
    // Sort the set, for example, in reverse 
    // integer order for a set of integers
    return originalSet.sort(function(a,b) {
                              return a < b;
                           });
    }
insight.addSetSorter('MySet',setSorter);
</script>

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