Rodger's helpful scripting tips #1 - Variable naming convention

Rodger's helpful scripting tips #1 - Variable naming convention

Hi everyone. I see many posts about scripting (deluge) issues and automation issues. At our business, we have developed many simple code snippets which I would like to share with you in the hopes that it helps you automate your businesses more to save you time and money.

But first, a bug bear of mine is variable naming convention. When we started, we struggled with a naming convention in our functions which was based on the horrible Zoho default naming convention.... "response" anyone? We picked up these tips from Joel Lipmann(?) who I have no affiliation with.

We have 5 major categories of variables/objects in Deluge 

Records
Maps
Lists
Collections
Variables

The naming convention we use is "x_name" where "x" is the first letter of the category. i.e

r_contact would be a Contact Record
m_contact would be a Map for a contact record
l_contacts would be a list of contacts
c_contacts would be a collection of contact records (you can also use l_contacts for a collection unless you're using lists and collections in the same function)
v_error would be a variable for an error message

You see the pattern? In this way, if you need to get information from a record, you type "r" and only the record objects come up in the list pop-up

It also makes loops easier to declare and read. i.e instead of 

  1. for each ele in contacts
  2. {
  3. }

it would read

  1. for each contact in l_contacts
  2. {
  3. }

Standard Zoho naming convention would use "contact" as the name for the contact record, so we can't use "contact" in the for each loop. However we can use the above naming convention because our contact record would be named r_contact, so our for each loop reads much more naturally as "For each contact in the list of contacts"

Finally, we don't use "response" in anything really. Give your tasks a descriptive name that allows you to understand what the task is doing. i.e

response = invokeURL tells you nothing unless you read the subsequent code, whereas

renameFile = invokeURL tells you exactly what that code block is doing. It also makes it much easier to use in subsequent code if you need to get information out of the response message for the task. i.e renameFile.get("data").get....etc

Hope this helps! This naming convention only has a minor effect on simple scripts, but when you start dealing with multiple records, multiple lists and when your scripts get up into the hundreds of lines or more, a good naming convention makes it much easier to code and debug.

    Access your files securely from anywhere

          Zoho Developer Community




                                    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

                                                • Zoho CRM Functions 53: Automatically name your Deals during lead conversion.

                                                  Welcome back everyone! Last week's function was about automatically updating the recent Event date in the Accounts module. This week, it's going to be about automatically giving a custom Deal name whenever a lead is converted. Business scenario Deals are the most important records in CRM. After successful prospecting, the sales cycle is followed by deal creation, follow-up, and its subsequent closure. Being a critical function of your sales cycle, it's good to follow certain best practices. One such
                                                • Custom Function : Automatically send the Quote to the related contact

                                                  Scenario: Automatically send the Quote to the related contact.  We create Quotes for customers regularly and when we want to send the quote to the customer, we have to send it manually. We can automate this, using Custom Functions. Based on a criteria, you can trigger a workflow rule and the custom function associated to the rule and automatically send the quote to customer through an email. Please note that the quote will be sent as an inline email content and not as a PDF attachment. Please follow
                                                • Function #50: Schedule Calls to records

                                                  Welcome back everyone! Last week's function was about changing ownership of multiple records concurrently. This week, it's going to be about scheduling calls for records in various modules. Business scenario Calls are an integral part of most sales routines.. Sales, Management, Support, all the branches of the business structure would work in cohesion only through calls. You could say they are akin to engine oil, which is required by the engine to make all of it's components function perfectly. CRM
                                                • Function #37: Create a Purchase Order from a Quote

                                                  Welcome back everyone! Last week, we learnt how to calculate the total number of activities for a lead and further take note of the activity count for particular dates. For instance, from the period of Demo to Negotiation. This week, let's look at a function that lets you create a Purchase Order instantly from a Quote. Business scenario: In any form of business, one of the most important things to do is to document the transactions. Naturally, negotiation, signing an agreement, placing an order,
                                                • Function-2: Round-Robin assignment of records

                                                  Welcome back folks! Last week, we saw how to update sales commission in quotes using a custom function. This week, let's see an interesting use case asked by many of you - auto-assignment records by round-robin method. Business scenario: Right now, the solution allows you to auto-assign leads from web form and imported lists. Let us look at a need where you want to auto-assign leads from in-bound calls in a round-robin method, across modules. Prerequisite: You must create a permanent record in the


                                                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 Campaigns Resources


                                                                            Zoho CRM Resources

                                                                            • CRM Community Learning Series

                                                                              CRM Community Learning Series


                                                                            • Kaizen

                                                                              Kaizen

                                                                            • 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


                                                                                  Zoho Show Resources


                                                                                    Zoho Writer Writer

                                                                                    Get Started. Write Away!

                                                                                    Writer is a powerful online word processor, designed for collaborative work.

                                                                                      Zoho CRM コンテンツ






                                                                                        Nederlandse Hulpbronnen


                                                                                            ご検討中の方





                                                                                                  • Recent Topics

                                                                                                  • Regarding GST Report Issue in Zoho Books

                                                                                                    Hi, Right now, the very important point from my end is this Zoho Books issue. Here, you can see that we have created the invoice with the items of account sales and expenses. The journal is also correct. The profit and Loss statement is also correct.
                                                                                                  • Default Ship To Address on Purchase Orders cannot be different than Organization Address

                                                                                                    Our organization address is not where we want shipments delivered, it is just a mailing address. We would like to change the Ship To address on our PO's so that by default it is our warehouse (not the mailing address). I understand that when creating
                                                                                                  • Function #57: Automatically group items in invoices based on categories

                                                                                                    Hello everyone, and welcome back to our series! As a business expands and new product lines are launched, it becomes important to organize the items for better inventory management. The Category field in Zoho Books helps here by allowing you to add and
                                                                                                  • Differences between Zoho Books and Zoho Billing

                                                                                                    Without a long drawn out process to compare these. If you were looking at these Books and Billing, what made you opt for one and not the other. Thanks
                                                                                                  • unable to import transactions into zoho books

                                                                                                    I download a csv with separate columns for deposit and withdraw. The sample has zero's in the blank spaces so I ensure mine does too. When I try to import it says the fields must have values greater than zero.
                                                                                                  • Zoho Forms Unable to Save Account Numbers with a Leading Zero

                                                                                                    We are using Zoho Forms to for rental applications. It is working well, except for one thing:  when a user enters their bank account information, and that account number actually starts with a ZERO (like 00123456) the Zoho form will return the value without
                                                                                                  • How to include GST% in PO amount?

                                                                                                    Currently when I raise PO, the basic price of the item is used. However, the GST is not calculated and added along with the basic amount. I have added a Custom field for GST in the PO but I need Zoho Inventory to calculate the GST amount and add it with the Basic price to give me the final PO price.
                                                                                                  • sitemap in zoho sites not updating

                                                                                                    I checked my sitemap and it has not added any updates. Do I have to generate one manually all the time or is zoho sites suppose to generate and update it?
                                                                                                  • I trying to connect our PM tool but API shows failure

                                                                                                    Hi All, in ZOHO CRM when an enquiry stage is moved to WON then I have created a rule to trigger POST URL to thrid party AP and then create a function for mapping with below code void automation.kytesfunctions(String enquiryId) { // Fetch enquiry details
                                                                                                  • Sample Ticket - Created from Bot Preview

                                                                                                    Why is Zoho desk adding bot created tickets?
                                                                                                  • Webhook data is not being received

                                                                                                    We’ve set up the webhook with a public URL that returns a 200 status on Postman. However, when we ran a test, we didn’t receive anything in the req.body object or see any data from the POST request. As a team of freshers still learning the ropes of development,
                                                                                                  • Number of Workflow runs

                                                                                                    Is there a way in Zoho desk to see statistics regarding workflows, rules and other automation objects? Would be nice for several reasons: You could ensure that your workflows are actually running. You could determine which ones weren't being used so you
                                                                                                  • Mail is no longer populating CRM contacts

                                                                                                    Hi! For the last few days, my mail hasn't been populating my CRM contacts. Even people I email multiple times per day. In fact, it keeps trying to send mail to myself. Notice, I started typing Amy and only got as far as, "Am" and it suggested myself.
                                                                                                  • Zoho Support is indeed shocking and difficult to get a response with

                                                                                                    All our business emails have an auto-foward set up on them so that they also go to our GMAIL accounts so that we receive them to the relevenat people. The emails are indeed auto forwarding and arriving to our GMAIL accounts but when you log into your
                                                                                                  • How to get a list of selected records into a button-function? Here is how!

                                                                                                    So, you might know already how to get a button on a page somewhere and perform actions with a function when pressed, but how about a button that only works with the records you selected in the list view? The button selected is a custom button in the modules
                                                                                                  • How to Add Break line / Return on button click

                                                                                                    I need to return the text concate with difference field from lead with line break i try "\r" ,"\n" "<br>" return "ali \r\n <br> baba"; None of above work.  i expected result something like this  ali baba but got this  ali \r\n <br> baba so, how can i
                                                                                                  • How to get batch number of item by api?

                                                                                                    Hi there, Is there any way to get batch number of item by api? Batch number is the batch reference number in https://www.zoho.com/inventory/help/advanced-inventory-tracking/batch-tracking.html . When I call the https://www.zoho.com/books/api/v3/#Items_Get_an_item
                                                                                                  • Announcing new features in Trident for Windows (v.1.18.6.0)

                                                                                                    Hello Community, Trident for Windows is here with some new features to elevate your workplace communication. Let's take a quick look at what's new. Ask and send read receipts for emails You can now request read receipts for specific emails while composing,
                                                                                                  • Dialing Microsoft Teams Phone Service via Zoho CRM

                                                                                                    I am using the VOIP option in Microsoft teams for my office phone system. I was hoping to have a way to dial numbers directly from Zoho CRM, but don't see anything in the Teams Integration or in the Telephony integration that will enable this. Does anyone
                                                                                                  • Increase subscription prices for existing subscriptions

                                                                                                    Hi, Does anyone know how we could achieve the ability to increase the subscription fee for our existing customers based on a % increase. We are not yet using Zoho Billing (Subscriptions) and I'm not sure if it is a good fit for us. But we would need to
                                                                                                  • Why developing custom function development made so difficult for Zoho Projects!!

                                                                                                    Hi Zoho Team, I am trying to write function to automate a process but whatever API name or Column Name I use, the API isn't populating certain fields. Even the standard fields aren't getting populated through API. It's already exhausting to find all API
                                                                                                  • Data not visible in sheet cells

                                                                                                    I'm having an issue where my data is not visible in my sheet cells. If I click on an individual cell, the data does display above in the little "fx" box. But all the boxes in the sheet just look blank. My collaborators do not have this issue. I have checked
                                                                                                  • Function #20: Custom calculation in item table of invoices

                                                                                                    When you create an invoice in Zoho Books, the 'Amount' of a line item is typically calculated as the product of the "Quantity" and the "Rate" of the item. For instance, if an item has a sales rate of $50 and a quantity of 5 is sold, then the amount would
                                                                                                  • PO receive limitations

                                                                                                    It is VERY common to receive more or less that the PO quantity. It's totally ludicrous to limit the maximum receive to the PO quantity! What if the receive is 0.00001 less than the PO quantity - it leaves the PO as "Partially received" The current options are to edit the PO manually before finalizing the receive, an outrageous situation ! Please Zoho guys - this is an infuriating oversight & can be easily resolved by introducing the option as shown in the attached document ......
                                                                                                  • Why don't we have better integration with Mercado Pago or Pagseguro?

                                                                                                    Currently, the integration between Zoho Commerce and Mercado Pago for Brazil is very poor... Since it is old, it does not include the main payment method in Brazil today, which is PIX. Is there a date for this to finally be launched? There are numerous
                                                                                                  • Why is there no integration with native Brazilian shipping methods?

                                                                                                    Zoho Commerce is a powerful platform for e-commerce, but its lack of integration with native Brazilian shipping solutions is a significant limitation for users in Brazil. Integrating with popular shipping providers like Correios, Frenet, and Kangu would
                                                                                                  • Alert for Back Navigation in Zoho Creator Widgets on Mobile Apps

                                                                                                    In Zoho Creator widgets, when a user navigates back on mobile devices, the data within the widget is reset. This leads to a loss of any unsaved changes or inputs, causing frustration for users. To enhance user experience, we need to implement a confirmation
                                                                                                  • Mapping Zoho Projects into Cliq Channels

                                                                                                    why arent all the Zoho Projects listed from the drop down menu when trying to Map them into Zoho Cliq Channels. The system doesnt allow me to type the name of the project but gives a drop down of a list of projects however it doesnt give me a list of
                                                                                                  • Input GST Reversal for damaged goods

                                                                                                    In our line of business, some items are damaged and we are doing inventory adjustments to remove them from stock. However, as per GST guidelines, there is a specific rule that we have to reverse Input GST availed for such items and needs to be reported
                                                                                                  • Develop and publish a Zoho Recruit extension on the marketplace

                                                                                                    Hi, I'd like to develop a new extension for Zoho Recruit. I've started to use Zoho Developers creating a Zoho CRM extension. But when I try to create a new extension here https://sigma.zoho.com/workspace/testtesttestest/apps/new I d'ont see the option of Zoho Recruit (only CRM, Desk, Projects...). I do see extensions for Zoho Recruit in the marketplace. How would I go about to create one if the option is not available in sigma ? Cheers, Rémi.
                                                                                                  • Canadian Anti Spam Law

                                                                                                    In order to be able to comply with the new Canadian Anti Spam Law, I need to send out a Confirm Subscription email to all of our existing contacts. If I use the Subscribe tag, the user gets the following message: Registration Failed. Sorry! This contact is already present in the selected list. You can check this with your update profile link. If I include an 'Update Profile' link, it then sends an email which does not arrive immediately. Can you provide a tag or URL I can put in a Campaign Email
                                                                                                  • How to bulk update lookup fields

                                                                                                    "I have a primary key named Product SKU in one form called Master SKU (which contains details like price, color, size, etc.). I also have another form called FBA, which has the same primary key, Product SKU, and contains stock quantity information for
                                                                                                  • Change work hours per day for employees

                                                                                                    Hello, Is there a way to modify the work hours per day for employees in Zoho projects? This would be helpful for resource allocation to more accurately see when an employee who works 35 hours a week vs 40 hours has a full schedule. Thanks.
                                                                                                  • Record GST Paid for Imported Goods

                                                                                                    In Australia, goods that imported from overseas needs to pay GST per invocied value. In most case, the freight forwader (logistic agent) paid this on behalf of importer (us), and invoice us in together in their freight invocie.  How do we setup a proper
                                                                                                  • Unable to produce monthly P&L reports for previous years

                                                                                                    My company just migrated to Books this year. We have 5+ years financial data and need to generate a monthly P&L for 2019 and a monthly P&L YTD for 2020. The latter is easy, but I'm VERY surprised to learn that default reports in Zoho Books cannot create
                                                                                                  • Bulk Editing Multiple Invoices with Overwriting at time of upload

                                                                                                    Hello, I would like to edit a few 100 invoices. Only the HSN needs to be updated. When I am trying to upload the excel sheet with the data updated, I get an error: The Invoices are skipped as they already exist. I know the invoices exist but I would only
                                                                                                  • Oauth Redirects me to sign in page

                                                                                                    I am developing a postman script for me to securely get my credentials via Zoho Vault. With that, I need to authorize my postman to be able to access Zoho Vault. I am currently on Step 1 in this Zoho Vault | API Reference which redirects me to this guide
                                                                                                  • Here's why you should refrain from using EasyShip

                                                                                                    This is a screen recording which shows EasyShip performance issues. Note well! While we do use the Zoho-to-Easyship integration, the problems are wholly on the EasyShip side. The actual integration of data to EasyShip, and status updates back to Inventory,
                                                                                                  • How can I create a billable expense.?

                                                                                                    Hi, I've a bill of an expenses related to printing and stationary account but it recorded in non-billable expense category. How can I record this expense in billable category. Below is the pathway I've used to record the expense. Purchases. Expenses Click
                                                                                                  • Introducing Sub-Accounts in Zoho Books!

                                                                                                    Hello Everyone, Sub-Accounts is LIVE! Yes, you read it right. The much needed and most requested feature is now live in Zoho Books. The sub-accounts feature in Zoho Books will help you to classify your accounts further which will give you a more detailed view of your accounts while running reports. You can create sub-accounts for the below Accounts: Asset Cost of Goods Sold Expense Liability Fixed Asset Other Asset Other Current Asset Long Term Liability Other Current Liability Other Liability Other
                                                                                                  • Next Page