Skip to main content

Posts

Showing posts from 2017

Uploading files to Zoho CRM using Node.js

I couldn't find any docs on using Node to attach files to Zoho CRM, so through trial and error came up with the below:


Here I'm using request to provide a readStream pointing at a remote file but you could equally use fs.createReadStream('./myFile.blah') to upload a local file.

Custom buttons that handle multiple records

One powerful technique in Zoho Creator is to have a custom action that you can trigger on multiple records by ticking the checkboxes and then unleashing the custom action. I had a client ask me to do the same thing in Zoho CRM, i.e.

I couldn't figure out how to do this initially as the docs only mention how to do it with one record at a time but after a bit of debugging and support from the CRM team, I discovered the solution. When multiple records are selected, the IDs get sent as a pipe delimited string:


Knowing that, it's simple to write a corresponding custom function. You just have to turn the string into an array of IDs with this code IdsList = input.IdsStr.toList("|||");

Here's a sample function the Zoho team gave me:

string custombutton.SendMassEmail(string IdsStr) {
  IdsList = input.IdsStr.toList("|||");
  for each IdStr in IdsList
  {
    operationsDetails = zoho.crm.getRecordById("CustomModule1", IdStr.toLong());
    sendmail
    (
      To …

Applying clean code principles to Deluge script

Robert Martin's seminal book "Clean Code: A Handbook of Agile Software Craftsmanship" lays out a set of best practices for writing code that is easy to understand and therefore easy to maintain. The examples he uses are for Java code but that does not mean it is not applicable to any other language including Deluge script.

Some of the principles I think are particularly valuable are:

1. Use meaningful variable names
I've worked with quite a few subcontractors who use really weird and indecipherable variable names like "a" and "ref" or "B22". It leads to all kind of problems down the line because only the original programmer has any clue what the single letter variable actually means.

I recently encountered an issue where code was written with Excel cell references based on an Excel specification from the client.

One of the On Input scripts looked like this:

E22 = B26 / B5;

This was exactly what was in the Excel specification but the prob…