Skip to main content
A map is a collection of key-value pairs. Both the key and the value are strings. The elements in a map are automatically sorted on their keys. The Map class supports two constructors. The default constructor accepts no parameters and initializes a Map with an empty key-value pair collection. The other constructor accepts a String.

Constructors

Map()

The default constructor. Called with no parameters, it creates an empty Map.

Map(String)

Pass a String containing key-value pairs separated by "
" like this: “key=value
key=value
key=value,…”

Methods

insert(String, String)

Adds a new key-value pair to the map.
Returns: CRMScript.Native.Map - A reference to itself.
This function will reset the internal iterator in the map.
Example:

exists(String)

Checks if the map contains the given key.
Returns: CRMScript.Global.Bool - True if the key exists in the map. Example:

size()

Counts the elements in the map and returns that number.
Returns: CRMScript.Global.Integer - The number of elements in the map.
An empty map has size == 0.
Example:

get(String)

Returns the value for the given key.
Returns: CRMScript.Global.String - The value for the given key. Example:

getKey()

Returns the key pointed to by the map iterator.
Returns: CRMScript.Global.String - The key pointed to by the internal iterator. Example:

getVal()

Returns the value pointed to by the map iterator.
Returns: CRMScript.Global.String - The value pointed to by the internal iterator. Example:

getWithFallback(String, String)

Returns the fallback value if key does not exist.
Returns: CRMScript.Global.String - The value of key, or fallback value if key does not exist. Example:

increaseValueForKey(String, Integer)

When working with numeric strings, you can increment values stored in the map. Provide the key to look up the element and the value to add to the currently stored value.
Returns: CRMScript.Global.Void
You can pass the increment as either Integer or Float.
Example:

increaseValueForKey(String, Float)

When working with numeric strings, you can increment values stored in the map. Provide the key to look up the element and the value to add to the currently stored value.
Returns: CRMScript.Global.Void
You can pass the increment as either Integer or Float.
Example:

remove(String)

Removes the element with the given key.
Returns: CRMScript.Global.Void Example:

clear()

Removes all elements from the map.
Returns: CRMScript.Global.Void Example:

eof()

Returns true if the map iterator has moved past the end of the map, otherwise false.
Returns: CRMScript.Global.Bool - True if the internal iterator is past the end of the map, otherwise False.
That eof() returns true is not the same as the map is empty. It can be, but it doesn’t have to be. Use size() to check if the map is truly empty.
Example:

first()

Rewinds the internal iterator to the 1st element. Returns false if the map is empty.
Returns: CRMScript.Global.Bool - True if map is not empty, otherwise false. Example:

next()

Moves the map iterator to next position. Returns false if eof().
Returns: CRMScript.Global.Bool - False if eof(), otherwise true. Example:

toJson()

Converts the Map to JSON.
Returns: CRMScript.Global.String - The Map represented as JSON string. Example:

fromJson(String)

Converts a JSON string to a map. Format: {"key": "value", "foo": "bar"}
Returns: CRMScript.Global.Void Example: