Triggering Function from Notes in Zoho CRM

Unlike other modules in CRM, Workflow Rules doesn’t allow you to set “Notes” as a function trigger. Till that day arrives, we have found a workaround that enables function triggering from Notes (create/edit). Here’s the idea:

  • Enable Notifications API for the Notes module that sends data on trigger of Notes (edit/create) to a serverless function in CRM.
  • The serverless function receives the Note ID along with other data and executes the custom function.

Cool Ideas to Use the Function

Here’s an example of an application. Suppose keeping Notes in a Deal is a mandatory procedure when it comes to following up on Deals in your organization. You need to know when a Deal was last “followed-up” to review dormant Deals. You can’t rely on “Last Activity Time”, because you have a daily scheduled function that updates a custom field in Deals. You need to know the time stamp of when a Note is last created/edited in the Deal.

Configuration

The following Zoho CRM Connection scope is needed:

  • ZohoCRM.notifications.ALL

Create a Serverless Function in Zoho CRM

  • If you’re not familiar with the idea of a serverless function, please refer to this post.
  • In the serverless function, set crmAPIRequest as a string argument. Assuming all you need here is the information of the Note record, you can just get the ID, then use a getRecordsbyID function to fetch the record details.
    • When you use crmAPIRequest.get(“body”), it will return you the ID in a form of a list. To get the ID, .get(0) is used to get the first index.
				
					id = crmAPIRequest.get("body").get(0);
note = zoho.crm.getRecordById("Notes", id);
				
			
  • Tip: To test that the setup is working initially, you can add a sendmail function in the serverless to send the response to your email.
  • Save the serverless function and create an API key for it (you need this key to enable notifications in the next step).

Enable Notifications

Notification APIs allow you to get instant notifications whenever an action is performed (create/update/delete) on the records of a module. The system notifies you of the event to the URL provided. The CRM serverless function API key will be set as the URL here.

  • channel_id
    • The given value is sent back in notification URL body to make sure that the notification is for a particular channel. Can be any arbitrary number.
  • events
    • The module action(s) for triggger (Module.action). The possible actions are create/edit/delete.
  • channel_expiry
    • Notifications expiry time. Maximum of only one day from the time they were enabled. If it is not specified or set for more than a day, the default expiry time is for one hour. Accepts only Zoho date-time format.
    • Here, we would want to set the maximum expiry (1 day after enabling notifications) and have a scheduled function to run daily so that the notification stays active at all times.
    • Check out this post on how to get the current Zoho date-time and convert it into a parseable format for update.
  • notify_url
    • URL to be notified (POST request). Whenever any action gets triggered, the notification will be sent through this notify url.
    • Insert the Zoho CRM serverless function API key here.
				
					param = 
{
  "watch":
   {
     {
        "channel_id":"1",
        "events":{"Notes.create","Notes.edit"}, 
        "channel_expiry":"INSERT_DATE_TIME_HERE",
        "notify_url": "INSERT_SERVERLESS_FUNCTION_API_KEY_HERE"
     } 
   }
};

response = invokeurl
[
	url :"https://www.zohoapis.com/crm/v2/actions/watch"
	type :POST
	parameters:param + ""
	connection:"INSERT_ZOHO_CRM_CONNECTION_HERE"
];
info response;
				
			

Note: To check if your notification is active, you can use the notification details API.

Now that you have enabled notifications, you can test the signal by creating/editing a CRM note. On success, you will be able to see the payload data.

  • If you have sendmail configured in the serverless function, you can verify that the setup is working by receiving the data in your email.

Once this is done, you’re ALL SET! You’ve now successfully set up a Note action (create/edit) as a workflow trigger where you can configure custom actions in the serverless function.

Click here to copy these scripts. For more Zoho-wizardry, check out our GitHub page. And, for more information on Zoho CRM, take a look at our detailed comparison of CRM and its top competitor, HubSpot.

Contact Us!

Book a free 30-minutes consultation with a Zoho expert or send us an email

Related Resources