Skip to main content
Skip table of contents

buildMap

A logic command that creates a Map whose entries can be initialized with any logic commands that create variables.

Every child command of buildMap that normally creates a variable will not create that variable, but instead create a new entry into the Map being created by this parent command. The name of the variable, typically defined with an attribute named var, will be the key of the Map entry and the variable's value will be the value behind that key. If there is more than one child command creating a variable with the same name, the value of the Map entry will be set by the last command evaluated.

Child commands

Any variable-creating or control command can be a child of buildMap.

Attributes

var

Required

Value type

EL-evaluated

Yes

String

No

Defines the name of the variable that will hold the new Map.

ordered

Required

Value type

EL-evaluated

No

Boolean

Yes

Defines whether the new Map will be such that its entries will appear in a predictable order when looped through with its keySet() or values() methods. If the resolved value is true, the order is defined for iteration, otherwise the iteration order is more or less random.

If not defined, value of false is used as the use cases in which a Map's contents need to be iterated through in some manner, and the order would matter, are not particularly common. 

Examples

Make use of the buildMap command when you want to easily create Maps with some content in them. The following builds a Map with three entries created by the set, query and setCollection commands:

CODE
<buildMap var="dataMap"><set var="name" value="${displayName}"><query var="relatedItems" select="SELECT Id, Name FROM Custom_Item__c WHERE Id = '${id}'"><setCollection var="selectedItems">

It is possible to also use buildMap as buildMap's child. In this case any child commands of the child buildMap will only create entries into its Map, which will then become the value of an entry in the parent buildMap's Map. The following would create a Map with the keys "defaultConfiguration" and "builtItems", both of which have a Map as the value:

CODE
<buildMap><buildMap var="defaultConfiguration"><set var="color" value="${defaultColor}"><set var="model" value="${defaultModel}"><buildMap var="builtItems"><setCollection var="basic"><setCollection var="special">

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.