Loading
Visual Studio Code Based Modeler for Consumer Goods Cloud
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          createDictionary()

          createDictionary()

          Dictionary API is used to create dictionary function. Dictionary is a small structure that allows the storage of key value pairs. There are no restrictions assigned to either the keys or the values.

          Required Editions

          Available in: Lightning Experience in Professional, Unlimited, and Enterprise Editions that have Consumer Goods Cloud enabled.

          Description

          A dictionary object is created by calling utils.createDictionary().

          The following methods are used:

          • keys(): Returns all stored keys as an array.
          • add(<key>, <value>): Adds or overwrites an entry.
          • remove(<key>): Removes an entry without returning the value.
          • get(<key>): Returns the value for the given key. Is undefined if the key is unknown.
          • containsKey(<key>): Checks for the existence of a key. Returns true if the key holds some value (even undefined). Returns false if the key is unknown.

          Example

          Example
          Example

          var dict = Utils.createDictionary();

          dict.add(1, 23);

          dict.add(2, "Hello");

          dict.add(42, true);

          Each method and the return value is explained below:

          Method: dict.keys();

          Return Value: ["1"," 2", "42"]

          Method: dict.containsKey(1);

          Return Value: true

          Method: dict.containsKey(10);

          Return Value: false

          Method: dict.get(42);

          Return Value: true

          Method: dict.get(2);

          Return Value: "Hello"

          Method: dict.remove(1);

          Method: dict.keys();

          Return Value: ["2", "42"]

           
          Loading
          Salesforce Help | Article