Map Manipulations

Map Manipulations

This guide will help you with the following:
  1. Create Map 
  2. Put Key 
  3. Put All Key 
  4. Remove Key 
  5. Clear Map
Maps provide a more general way of storing elements. Map collection type in Deluge allows you to store a pairs of elements, such as "keys" and "values", in which each key maps to one value. Conceptually, Lists are Maps with numeric keys.
The following sections explain the different types of map variables available in Deluge.

Create Map

The CreateMap deluge syntax creates a new empty map expression. If the target map variable is already defined as map variable, then all its content will be erased. The map expression related tasks (put, putAll, remove, clear) and opertions can be done only if the map variable is defined.

map() - map constructor to create and initalize map variable.
{} - Holds map values. Handy syntax for creating map with some initial values.

Example:  hdrs = { "Email" : "support@mydomain.com", "Passwd" : "mypassword", "accountType" : "HOSTED_OR_GOOGLE", "service" : "cl" };

Example
In the following sample code, a map named map1 is defined in the on add -> on load block and initialized with the map() constructor.
  1. map1 = map(); // map constructor to initalize the map variable named map1.
  2. map1.put("creator","http://crm.zoho.com");
  3. map1.put("writer","http://writer.zoho.com");
  4. map1.put("sheet","http://sheet.zoho.com");                                       
  5. // Following is map constructor to declare a variable with default values
  6. hdrs = { "Email" : "support@mydomain.com", "Passwd" : "mypassword", "accountType" : "HOSTED_OR_GOOGLE", "service" : "cl" };
 

Put Key

The Put Key Deluge task inserts a key-value pair into the map variable. If the specifed key is already present in the map-variable, then the key's associated value will be replaced with a new value.

Syntax
  1. <map1>.put(<key>,<value>);

In the above syntax,
  1. <map1> refers to the name of the map variable.
  2. <key> refers to the key to be inserted to the target map variable.
  3. <value> refers to the value to be associated with the given key in the target map variable.
Example
  1. map1 = map();
  2. map1.put("John", "India");
  3. map1.put("David", "USA");
 

Put All Key

The Put All Key Deluge task inserts all key-value pairs into the specified map variable. If the key(s) are already present in the map-variable, then the key's associated value will be replaced with new value.
Syntax
  1. <target-map variable>.put(<source-map-variable>);
In the above syntax,
  1. <target-map variable> is a map variable in which the action take place
  2. <source-map-variable> is a map variable from where all the key-value mappings will be added to the above target map variable
Example
In the following sample code, the key-value pairs in the "Games" map is added to the "Sports" map.
  1. {
  2. Games=map();
  3. Games.put("Cricket","Sachin");
  4. Games.put("Tennis","SteffiGraf");
  5. Games.put(("Badminton"),"SainaNehwal");
  6. Sports=map();
  7. Sports.put(Games);
  8. }

Remove Key

The Remove key Deluge task removes the specified key and its associated value from the target map variable.

Syntax
  1. <map-variable>.remove(<key-name>);
In the above syntax,
  1. <map-variable> refers to the map name from where the specified key and its associated value will be removed.
  2. <key-name> refers to the key to be removed from the map variable
Example
In the following example, the key-value pair ("John", "India") available in map1 will be removed.
  1. map1 = map();
  2. map1.put("John", "India");
  3. map1.put("David", "USA");
  4. if(map1.containKey("John"))
  5. {
  6.       alert("John is lived in " + map1.get("John"));    
  7. }
  8. else
  9. {
  10.       alert("No Information available");
  11. }
  12. map1.remove("John");

Clear Map

The Clear Map Deluge task removes all the key-value mappings from the map.

Syntax
  1. <map>.clear();
In the above syntax,
  1. <map> refers to the name of the map to be cleared.
Example
In the following example, all key-value mappings in "map1" will be removed.
  1. map1 = map();
  2. map1.put("John", "India");
  3. map1.put("David", "USA");
  4. alert(map1.size() + "entries available"); //before clear task, the map variable's size is 2
  5. map1.clear();
  6. alert(map1.size() + "entries available"); //after clear task, the map variable's size is 0 

    Zoho CRM Training Programs

    Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

    Zoho CRM Training
      Redefine the way you work
      with Zoho Workplace

        Zoho DataPrep Personalized Demo

        If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

        Zoho CRM Training

          Create, share, and deliver

          beautiful slides from anywhere.

          Get Started Now


            Zoho Sign now offers specialized one-on-one training for both administrators and developers.

            BOOK A SESSION








                                    You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                        Manage your brands on social media

                                          Zoho Desk Resources

                                          • Desk Community Learning Series


                                          • Digest


                                          • Functions


                                          • Meetups


                                          • Kbase


                                          • Resources


                                          • Glossary


                                          • Desk Marketplace


                                          • MVP Corner


                                          • Word of the Day


                                            Zoho Marketing Automation

                                              Zoho Sheet Resources

                                               

                                                  Zoho Forms Resources


                                                    Secure your business
                                                    communication with Zoho Mail


                                                    Mail on the move with
                                                    Zoho Mail mobile application

                                                      Stay on top of your schedule
                                                      at all times


                                                      Carry your calendar with you
                                                      Anytime, anywhere




                                                            Zoho Sign Resources

                                                              Sign, Paperless!

                                                              Sign and send business documents on the go!

                                                              Get Started Now




                                                                      Zoho TeamInbox Resources



                                                                              Zoho DataPrep Resources



                                                                                Zoho DataPrep Demo

                                                                                Get a personalized demo or POC

                                                                                REGISTER NOW


                                                                                  Design. Discuss. Deliver.

                                                                                  Create visually engaging stories with Zoho Show.

                                                                                  Get Started Now









                                                                                                      • Related Articles

                                                                                                      • Map Manipulations - Create Map

                                                                                                        This guide will help you with the following: Overview Syntax Examples Overview The create map deluge task is used to declare a map variable. Syntax To declare a map variable <variable> = Map(); To create a map variable with key value pairs <variable> ...
                                                                                                      • Map Manipulations - Clear map

                                                                                                        This guide will help you with the  following: Overview Syntax Example Overview The clear map deluge task empties a specified map variable by permanently removing all its key-value pairs. Syntax <map_variable>.clear(); This task can be used in the ...
                                                                                                      • Map Manipulations - Put Operation

                                                                                                        This guide will help you with the following: Overview Syntax Examples Overview The put deluge task inserts a specified key-value pair in a pre-defined map variable. Syntax <map_variable>.put(<key>, <value>); This task can be used in the following ...
                                                                                                      • Map Manipulations - Remove Key

                                                                                                        This guide will help you with the following: 1. Overview 2. Syntax 3. Example Overview The remove key deluge task removes a specified key and its value from a specified map variable. Syntax <map_variable>.remove(<key>); This task can be used in the ...
                                                                                                      • Map Manipulations - Put all keys

                                                                                                        This guide will help you with the following: Overview Syntax Example Overview The put all keys deluge task inserts all key-value pairs present in one map variable(map_variable2) to another map variable(map_variable1). Syntax ...
                                                                                                        Wherever you are is as good as
                                                                                                        your workplace

                                                                                                          Resources

                                                                                                          Videos

                                                                                                          Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                          eBooks

                                                                                                          Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                          Webinars

                                                                                                          Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                          CRM Tips

                                                                                                          Make the most of Zoho CRM with these useful tips.



                                                                                                            Zoho Show Resources