Zoho Tips

Using Zoho Connections to Invoke the API

By September 25, 2018 February 7th, 2019 No Comments

Using Zoho Connections to Invoke the APIWhen 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 fairly simple to set up a “connection” for the CRM API, and then refer to that connection when invoking the URL. Here’s how:

Setting up a connection for the CRM API

  • 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 the 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 Zoho API 2.0 documentation for more details.

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()

Sign up for expert Zoho training today

Want to learn more about Zoho’s products and services, and how they can help your business run more efficiently and stay more organized? Whether you already have Zoho, or you’re thinking about signing up, it’s a good idea to take advantage of all that Zoho has to offer. After all, by signing up for Zoho, you’re making an investment in your business and you want to get the most out of your investment. This is where we come in.

At Marks Group Live, we provide expert-led Zoho training. Our services include Zoho webinars, one-on-one Zoho support, live videos and more. Become a subscriber to see what we’re all about!

Megan Hagedorn

Author Megan Hagedorn

More posts by Megan Hagedorn