Introducing an easy way to access resources defined in the resources.json file

Introducing an easy way to access resources defined in the resources.json file

Dear Zoho Desk extension developers, 

We heard you; it is next to impossible to access the Zoho Desk resources created by an extension without knowing their unique values. For example, to access the fields created by an extension, you must know the ID or apiName of the field in the Zoho Desk organization. Without knowing either, it becomes challenging to access the information required. But worry not. We have now made it easy for you to retrieve resource details. 

We take pleasure in introducing a new capability intended to make extensions a bit more powerful and context-filled. This is the ability to include Zoho Desk resources, such as fields and webhooks, within your extensions. You can also access those resources through their unique identifiers, using Zoho Desk's module-specific REST APIs. 

(For detailed information on how to include Zoho Desk resources in an extension, refer to the Developer Guide.)

To support this functionality, we are introducing a new key called resourceName, which uniquely identifies resources created by extensions. Each resource you want to include in your extension must be specified in the resources.json file, and each resource must have a unique resourceName

The two resources that are currently supported in extensions are custom fields and webhooks. So, if you include these resources in your extension, make sure to specify a unique resourceName for each field/webhook you add. Just like all other resources, the resourceName key is also validated while packing the extension.  

Any new extension that you develop must contain the resourceName key if you choose to include Zoho Desk fields and webhook resources. As for older extensions, we have ensured backward compatibility to support the inclusion of resources. This backward compatibility will be supported only for 3 months, which is until January 9, 2020. Therefore, we request you to tweak the code of your extensions accordingly, before this date.

Here's a detailed overview of the resourceName key. 

How resourceName works
When you define a resourceName in the resources.json file, the ID and apiName (if available) of the resource are also mapped to it automatically. After this, you can use the ID and/or apiName (if available) in APIs related to the resource, as required.

You can also use the resourceName key to retrieve the ID or apiName of a resource.

Retrieving the ID and apiName of a resource
Using the resourceName value, you can retrieve the ID and apiName of a resource in one of the following ways:
  1. Through a merge field in the invoke API, or
  2. Using the client SDK

1. Through a merge field in the invoke API
In this method, you must specify the resourceName value in Zoho Desk's invoke API in the following format.
  1. {{resourceType.resourceName.id}} or {{resourceType.resourceName.apiName}}
Merge Field Details
  • resourceType should be fields or webhook, based on your use case.
  • id returns the fieldId or webhookId, based on the value in resourceType.
  • apiName returns the apiName of the resource. This key is applicable only to fields.
To get a clearer idea, refer to this example:
  1. var reqObj = {
  2. url: 'https://desk.zoho.com/api/v1/tickets/1000000017201',
  3. headers: {
  4. "Authorization": "Zoho-oauthtoken 1000.41a9b31ac5adaa187ba160e250a88551.15bd423103f52f4853c1bc7243b2085d",
  5.  "orgId": "15167075"
  6.  },
  7.  postBody: {
  8.   "cf": {
  9.   "{{fields.field1.apiName}}": "Testing"
  10.   }
  11.  },
  12.  data: {},
  13.  type: 'PATCH'
  14. }
The apiName of the resource is replaced when the invoke API call is made.

2. Using the client SDK
In this method, you must use the following syntax for retrieving resource details.
  1. ZOHODESK.get('extension.resource', {resourceName: "resourceName", resourceType: "resourceType"}).then(console.log).catch(console.log);
Sample Request
  1. ZOHODESK.get('extension.resource', {resourceName: "field1", resourceType: "fields"}).then(console.log).catch(console.log);
Sample Response
  1. {
  2.     "status": "success",
  3.     "extension.resource": {
  4.         "resourceName": "field1",
  5.         "id": "4000000020060",
  6.         "resourceType": "fields",
  7.         "apiName": "cf_counter"
  8.     }
  9. }
For instance, the following code snippet returns the list of fields in the ticket currently being accessed by the user.
  1. ZOHODESK.get('ticket.cf').then(console.log).catch(console.log);

Sample Response
  1. {
  2.     "status": "success",
  3.     "ticket.cf": {
  4.         "cf_counter": "12",
  5.         "cf_deal_id": "2288589490093"
  6.     }
  7. }


    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now