Suzanne Kirkland No Comments

When writing Custom functions in Zoho CRM, there are times that, when we add or update a record in the custom function, we need to trigger existing workflow.  The only way to do this is to use the Zoho API within the custom function when adding/updating the record and set the trigger to workflow.  With the new API 2.0, this can be a tad more cumbersome to first set up the “Client” get the refresh token and then copy and paste all the long strings into every custom function where you use the API.  Enter Connections!  It is soooo easy to set up a “Connection” for the CRM API, and then refer to that connection when invoking the URL – here’s how…

  • Setup->DeveloperSpace->Connections
  • Click Get Started or Add new Connection
  • Click the Zoho OAuth box

  • Enter a name and Choose the scope (in this example we selected ZohoCRM.modules.ALL) so that we can use it for any module in CRM

  • Click create and connect
  • Click Allow

To use the connection within your custom function, drag a “webhook” into the script.  Replace url with the API URL you need, enter the Request Method type, create your parameter map and refer to the connection name given when you created the connection.

Example: to insert a Lead record (see below for more info on params)

  • url: https://www.zohoapis.com/crm/v2/Leads
  • type: POST
  • parameters: params.toString()
  • connection: crmapi6

Refer to the API 2.0 documentation for more details: https://www.zoho.com/crm/help/api/v2/#create-specify-records

 

special note on parameters... It’s a little tricky to create the exact parameter string the crm API is looking for.  Here’s the sequence:

  • data = map() – put all your data fields into this map  [e.g. data.put(“Phone”,”888-555-1212″);]
  • dataList = list(); – add the data map to the dataList [dataList.add(data);]
  • triggermap = map() – build the trigger map[ triggermap.put(“trigger”,{“workflow”,”blueprint”,”approval”});]
  • params = map() – put data and trigger into the param map
    • params.put(“data”,dataList);
    • params.put(“trigger”,triggermap);
  • parameters: params.toString()

Leave a Reply

Your email address will not be published. Required fields are marked *