A map is a collection of elements that are organized in pairs of key and value.
You can think about maps like a Dictionary.
If you open up any Dictionary, what would you see?
Well you will see the word you are looking for and its definition(meaning), this is pretty much what a map is, the word is like the key and the definition is like the value.
This is how a map is defined:
def map_Name= [Key_1:Value_1, Key_2:Value_2,Key_3:Value_3]
So as you see you have a key and a value associated with that key.
When you search a element on the Map, you will search it by its key.
Notice that by default, the map key is assumed to be a string so you don’t need to include the key values in quotes. However, if any key value contains spaces you will need to use quotes around it like this:
def maxDaysByStatus = [Open:30, Closed:90, Pending:45, ‘On Backorder’:10]
Most of the times you will be using maps in your scripts, when you will want to call some web-service operation, as most of the SOA web-services, supported by Sales Cloud, use as parameters for their operations, maps.
For example:
If you have registered the Opportunity web-service in Sales Cloud, one of its operations is Delete Opportunity and a call to this operation would probably look something like this: adf.webServices.Opty.deleteOpportunity(opportunity)
The opportunity is the parameter of deleteOpportunity() operation and opportunity is actually a map, which you will have to define prior to calling the operation.
So the code for calling deleteOpportunity() could look something like this:
def var_ID = getAttribute('OptyId');
def opportunity =
[
OptyId :var_ID
]
adf.webServices.Opty.deleteOpportunity(opportunity)
As you can see the key of the map opportunity is OptyId and value is the variable var_ID.
The map opportunity has only one pair of key/value.