Groovy 14 – Map
A map is a collection of key-value pairs, similar to a dictionary. In a dictionary, you have words (keys) and their definitions (values). A map works the same way.
Defining a map:
def map_Name = [Key_1: Value_1, Key_2: Value_2, Key_3: Value_3]
Each key has an associated value. By default, keys are assumed to be strings, so you don't need to use quotes unless the key contains spaces:
def maxDaysByStatus = [Open: 30, Closed: 90, Pending: 45, 'On Backorder': 10]
Maps are often used in scripts, especially when calling web services in Sales Cloud. For example, when calling the Delete Opportunity operation of the Opportunity web service, you use a map as the parameter.
Example
def var_ID = getAttribute('OptyId') def opportunity = [OptyId: var_ID] adf.webServices.Opty.deleteOpportunity(opportunity)
In this example, the map opportunity has one key-value pair where the key is OptyId and the value is var_ID.