Skip to main content

Posts

Showing posts from 2018

Getting current time in a specified timezone using Deluge script

Recently I was working on a custom function for Zoho CRM which required me to get the current time in a specified timezone. I assumed that zoho.currenttime would give me the time based on the timezone chosen in the organisation settings but discovered that it always gives it to you in PST. The Zoho Partner team gave me this snippet to solve the problem: current_time_in_timezone = zoho.currenttime.toString("yyyy-MM-dd'T'HH:mm:ss", "Australia/Sydney").toTime("yyyy-MM-dd'T'HH:mm:ss"); If you need the current date, do: current_date_in_timezone = zoho.currenttime.toString("yyyy-MM-dd'T'HH:mm:ss", timezone).toDate(); To figure out what you can put in for the timezone part, refer to https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Using pdfkit on Heroku

I recently set up a PDF rendering engine on Heroku using the Python library pdfkit . There was a bit of extra work to get pdfkit working on Heroku. Step 1: Install the  wkhtmltopdf buildpack Step 2: Point pdfkit to the location of the wkhtmltopdf binary: config = pdfkit.configuration( wkhtmltopdf = './bin/wkhtmltopdf' ) pdf = pdfkit.from_string(html, False , options =options, configuration =config)

Updating Zoho CRM event participants via Deluge script

Helpful tips from Ajeet from the Zoho partner team that I couldn't find documented anywhere: Replace xxxxxx with event id Replace yyyyy with contact id resp = zoho.crm.getRecordById(" Events", xxxxxx); partlist = List(); partmp = map(); partmp.put("type","contact"); partmp.put("participant", yyyyy); partlist.add(partmp); mp = map(); mp.put("Participants", partlist); update = zoho.crm.update("Events", xxxxxxx, mp); info update; info partmp; However, this will work in such a way that, let's say there is an event with existing participants, on using this code to update participants, the existing participants will be removed and new participants updated via API will be included. Sincerely,  Ajeet | Partner team.

Gotchas when downloading PDFs from Zoho Creator using Node JS

I spent a confusing 90 minutes trying to figure out how to download PDFs from Zoho Creator from a Node JS API. (Backstory is that I wanted to be able to email a Zoho Creator HTML page as a PDF attachment to customers). There are two gotchas I discovered: 1. There is a 302 redirect from the URL that Zoho gives you in their documentation (e.g. https://creator.zohopublic.com/customer/app/pdf/HTML_Page/PUBLIC_SHARE_KEY) to a URL like this: https://creator.zohopublic.com/exportData.do?sharedBy=customer&appLinkName=app&viewLinkName=HTML_Page_Link_Name&privatelink=PUBLIC_SHARE_KEY&fileType=pdf You either have to use followRedirects or use the second URL. 2. Zoho Creator won't actually give you a real PDF unless you supply a realistic user agent. I spent a good hour trying to figure out why I kept getting 0 bytes back when downloading the PDF from my code. The solution was to pretend to be a browser to get the PDF.

Creating purchase orders using deluge script

I was working on a custom function for a client to create purchase orders automatically. Everything worked fine except the product details. When you look at the JSON for a purchase order, it uses "product" for the line items. However, if you try and do the same thing when creating a purchase order, it seems to completely ignore the "product" property. Fortunately Ruben came through with a video that explains how to solve this. You have to use "Product Details" as the key instead of "product". Here's a code snippet: