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
- for each ele in contacts
- {
- }
it would read
- for each contact in l_contacts
- {
- }
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.