Get the timezone of your leads

Business scenario:

It’s a no brainer that prompt call backs and engagement right through the purchase cycle have a direct bearing on your lead conversion. To do this, it is very important that you call/email your clients in their time zone. Wouldn’t it be great if your CRM automatically sorts your leads based on their time zone? The Function (custom function) I share today helps you do just that.

Add this function to the Leads module and fetch the time zone of the leads based on their address. We will make use of Google APIs to meet this requirement. Create a custom field in Leads module to capture the time zone details. Furthermore, you get the list view of the Leads module to display the time zone along with the name, contact number and the other fields. Segregate your clients based on their time zone and target your nurture programs accordingly. This ensures your sales calls and emails are addressed at the right time and help you win more deals.

Setting this function as a button is not a practical, so we suggest placing this function in a Workflow rule to incorporate this process into your business process.


Getting started with the function:

  1. Go to Setup > Developer Space > Functions > + Create New Function.
  2. Select Automation as Function type and click Next.
  3. Provide a name for the function. Add a description(optional).
  4. Copy the code given below.
  5. Click Edit Arguments.
  6. Enter the name as leadId and select the type as Int.
  7. Enter the name as zip and select the type as Int.
  8. Click Save&Execute Script.
  9. Click Save.

The Code:

data = getUrl("" + zip + "&key=xxxxxxxx");
result = data.getJSON("results");
geometry = result.toJSONList().get(0).getJSON("geometry").toJSONList();
location = geometry.get(0).getJSON("location");
lat = location.getJSON("lat");
long = location.getJSON("lng");
timezone = getUrl("" + lat + "," + long + "&timestamp=0900000000&key=yyyyyyyy").getJSON("timeZoneName");
update = zoho.crm.update("Leads", leadid.toLong(), {"Time_Zone": timezone});
info update;


  • Once the function is added, you can set the function in a Workflow rule to trigger it upon the creation of a lead.
  • Replace the "xxxxxxxx" in the code by getting the key from the following link.
  • Replace the "yyyyyyyy" in the code by getting the key from the following link.
  • In both pages, click Get A Key from the top-right of the page and give a Project name to get the keys.
  • The above code works only for API V2.0 and not the previous version.

Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips