map tutorial (Beginners)

map tutorial (Beginners)

Hello Zoho Creator fans,

I thought I would make a post about some info, tips, ideas, I have around the the Zoho Creator "map" feature....

The map feature can be extremely poweful if you know how to use it. Unfortunately, there isn't a ton of documentation in the Wiki about it's cababilities..

First talk about what a Zoho Creator map is....

A map holds data! You put data in it by first creating a key and then adding a value.

This is called a key, value pair. This key,value concept is used in well known data documents like XML & JSON. And guess what!? Outputted ZC Maps ARE VALID JSON! (Later tutorial)

Maps are great for the following things.......

1. Structuring your data

2. Passing MANY VARIABLES from a form to a funtion or vice versa. (Instead of say one string/Int,List value which can save you much loading and development time)

3. Ceating input agnostic data sets.. (later)

4. Posting JSON to API's using the postURL()/getURL() functions (later)

5. Creating multidimensional traversable arrays just like in other scripting languages (GREAT! later)


Creating a map... (It's so easy...)

//first name a variable.....

myMap = map();

So you just created a map myMap is the variable that holds your map data and map();

Now, we just need to add data to it!

myMap.put("key1","value1");

So "key1" is your key and "value1" is your string value associated with the "key1" key...

Let's add some more keys!

myMap.put("key2",2);

myMap.put("field3",false);

Ok, so now we have added two more keys to our "myMap" map and we added some values.. The "key2" key holds an integer, and "key3" holds a bool value..

Notice that you I CAN NAME MY KEYS WHATEVER I WANT! This is VERY IMPORTANT! If you have been playing with Zoho Creator Deluge Script for a while you will start to realize that you cannot dynamically change the "name" of a variable, but since our keys arent' actually a true variable we can dynamically name them.. We will talk about this more later but trust me this is a fantastic little detail that can be uber powerful if you know how to use it.


Getting Data from your LOCAL map.....(this is easy too!)

//Let's get "key1" from myMap

myKeyValue = myMap.get("key1");

There... now myKeyValue will == "value1"


Getting map values stored in a function....

FIRST IN MOST CASES IT'S A BAD IDEA TO CALL A MAP FUNCTION LIKE THIS....

myKey1Value = thisapp.mapFunction().get("key1");

myKey2Value = thisapp.mapFunction().get("key2");

Why? Because unless you added a paramter to the map function to only run a certain part of the map, the FUNCTION IS RUNNING THE WHOLE SCRIPT just to get your one map value... So each time you make a call to this mapfunction you are running the entire script. This won't slow you down with a small function but if you are making calls to web services or collecting records this is just NOT good form...

Like in all good programming it's better to save operations and create A LOCAL map variable... Here's how....

Store your map function key, value pairs in A NEW local variable....

myNewLocalMap = map.put(thisapp.mapFunction());

Now all your keys and values from your map function are IN YOUR LOCAL SCRIPT. Then you just get your values the same way as we did above....

myKeyValue = myNewLocalMap.get("key1");


Ok, there is more to come...

In my next post I will give the goods. This is just a basic post.

Stephen Rhyne

Owner

Rhyne Design






                            Zoho Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation
                                        • Sticky Posts

                                        • Merge and Store v1 API depreciation

                                          Hi Zoho Writer users, The Merge and Store v1 API allows you to store the merged document in Zoho WorkDrive. The response of this API will be returned with the document's ID only after the merge is complete. In Deluge, the maximum timeout for operation
                                        • Zoho Creator Developer's Conference 2017 !!!

                                          We welcome all our Creator Developers! You're invited to join us for our annual Zoholics Developers conference August 29th–31st! This is your chance to get training and guidance on Zoho Creator from our most knowledgeable custom app builders.       Zoholics Developers is a three-day event where you'll participate in interactive workshops to hone your app-building skills, get questions answered by Creator experts with personal one-on-one sessions, and connect with other Creator developers from around
                                        • Share your success story

                                          We would like to hear from our passionate users how much Zoho Creator has changed the way you work and benefited you. If you would like to share your story to us and be featured as a proud user of Zoho Creator, then this is for you. Fill up the form below and if you want to be included in a case study, we will get in touch with you to get further details. So what are you waiting for? Tell us your story. Charles


                                        Manage your brands on social media



                                              Zoho TeamInbox Resources

                                                Zoho DataPrep Resources



                                                  Zoho CRM Plus Resources

                                                    Zoho Books Resources


                                                      Zoho Subscriptions Resources

                                                        Zoho Projects Resources


                                                          Zoho Sprints Resources


                                                            Qntrl Resources


                                                              Zoho Creator Resources


                                                                Zoho WorkDrive Resources



                                                                  Zoho Campaigns Resources

                                                                    Zoho CRM Resources

                                                                    • CRM Community Learning Series

                                                                      CRM Community Learning Series


                                                                    • Tips

                                                                      Tips

                                                                    • Functions

                                                                      Functions

                                                                    • Meetups

                                                                      Meetups

                                                                    • Kbase

                                                                      Kbase

                                                                    • Resources

                                                                      Resources

                                                                    • Digest

                                                                      Digest

                                                                    • CRM Marketplace

                                                                      CRM Marketplace

                                                                    • MVP Corner

                                                                      MVP Corner

                                                                    





                                                                    




                                                                        Design. Discuss. Deliver.

                                                                        Create visually engaging stories with Zoho Show.

                                                                        Get Started Now