Hi Everyone,
We've been exploring custom functions which help in performing advanced automation tasks. Custom functions enable you to achieve possibilities based on your organization's requirements. Custom functions require user inputs that allow the function to operate specifically for your organization based on the data provided.
The User Inputs section
Zoho Desk team provides you custom functions in a uniform code format. We have the "user inputs section" at the beginning of most of our custom functions.
The code below demonstrates what the User Inputs section looks like in custom functions. The User inputs section lets you feed in customized inputs based on your organization/portal.
- // ----<<<< User Inputs format>>>>----
- logs = Map();
- deskUrl = "https://desk.zoho.com"; //Replace .com the domain based on your DC
- Orgid = "***********" //replace with org ID
- cfApiName = "cf_field_name";// replace with the API name of the custom field
- departmentId = ***********;// Replace *********** with your department Id
- templateId = "enter_the_email_template_id";
-
- from_email = "enter_the_from_email_address";
- // ----<<<< Code Section >>>>----
-
- logs.insert("templateId":templateId);
- if(templateId != "")
- {
- // info templateId;
Here's how you can add your portal-based inputs to the custom function:
- // ----<<<< User Inputs with data >>>>----
- logs = Map()
- deskUrl = "https://desk.zoho.au"; //DC is au
- Orgid = "10000000x7" //replace with the complete org ID
- cfApiName = "cf_country_name";// replaced with the API name of the field Country name.
- departmentId = 29x0x0x0x0x0x9;// Replace *********** with your department Id
- templateId = "1x3x00xx9x8xxx0x0x";
- from_email = "1x4x00xx1x0xxx0x0x";
- // ----<<<< Code Section >>>>----
- logs.insert("templateId":templateId);
- if(templateId != "")
- {
- // info templateId;
What makes the 'User Inputs' section valuable in custom functions?
Some developers prefer to include user inputs directly within the code in every line. However, using the dedicated User Inputs section offers several advantages: it keeps your code clean, enhances efficiency, and separates hard-coded values from the logic, making your custom function more manageable and easier to maintain.
In the User Inputs section, you’ll need to replace the sample values or placeholders with actual data. This is necessary because the Arguments option in the Custom Function script provides access to only a limited set of field values. In most cases, inputs such as Org ID, ticket ID, and API names must be entered in the User Inputs section to ensure the function runs correctly and is tailored to your organization/portal.
User Inputs: where to get the required values?
This section explores how to fetch the user inputs required for specific parameters. These inputs play a key role in helping you code custom functions tailored to your needs. In most cases, they include IDs related to your organization, tickets, custom views, departments, holiday lists, and more; each referring to a unique record ID within the Zoho Desk platform.
1. Zoho Desk Domain
Many user inputs begin with "replace .com based on the your DC".
The easy way to find your DC(data center) or location is from the browser's URL. Login to your Zoho account via this link, your DC is present after accounts. zoho.
For example : deskURL = "https://desk.zoho.com";
If your DC is IN, replace .com with in in the deskURL like this "https://desk.zoho.in". Based on your DC : eu/au/in, replace .com with the respective DC alone.
2. Org ID
To get the Org ID of your Zoho Desk portal, go to Setup >> APIs under Developer Space. You will find the Org ID under the API Plan details.
3. Ticket ID
To get the ticket ID, go to Tickets >> open the ticket for which you want the ticket ID. In the browser's URL, you will find an 18-digit number after the "/tickets/details/" section, which is the ticket ID of the particular opened ticket.
4. Contact ID
To fetch the contact ID, go to Customers and choose the contact for which you wish to find the Contact ID. In the browser's URL, you will find an 18-digit number at the end of the URL after the "/contacts/details/" section. This is the contact ID for the selected contact.
5. Account ID
To get the Account ID, click on Customers in your Zoho Desk portal, then click on Account on the bottom left of the window. Click on the account for which you want the account ID. Once the account is displayed, the 18-digit number at the end of the browser's URL after "/accounts/details/" is the Account ID for the selected account.
6. Agent ID
To fetch the Agent ID, go to Setup (S) >> User Management >> Agents. You can search the Agent using the Search space on the top left. Select the Agent for detailed view. The 18 digit number in the browser URL at the end after the "/user-control/agents/" is the Agent ID of the selected ID.
7. Department ID
Navigate to Setup >> Organization >> Departments >> select the department for which you want to fetch the ID. The URL in the browser has the department ID after the "/general/departments/" section.
8. Help Center ID
To fetch the ID of the Help Center, go to Setup >> Channels >> Help Center >> select the Help Center for which you want to fetch the Help Center ID, then click Customization. Now the browser URL will have the 18-digit number between #setup/channels/ <Help Center ID> and /hcCustomize.
9. ID of Business hours
To get the ID for a business hour configured, go to Setup >> Organization >> Business Hours. Select the Business hour to view the Business hour page. The browser's URL will have the business hour ID after "/businesshours/edit/" section.
10. ID of a Holiday list
To get the ID of the Holiday Lists configured, go to Setup >> Organization >> Holiday Lists. Click on the Edit button in the Holiday list to view the Holiday list page. You will find the Holiday list ID next to "/holidaylist/edit/" in the browser URL.
11. Email template ID
Navigate to Setup >> Customization >> Email Templates. Click on the Email template for which you need the ID. Once you've selected the Email template, you can locate the Email template ID in the URL of the email template page. It is found after the "/emailtemplates/edit/" section.
12. Custom field API name
When custom functions are triggered based on a specific field or a custom field created, they require the field's API name to be included in the user inputs.
To fetch the API names, go to Setup >> Customization >> Layouts and Fields >> Field list. You will find the API name for the respective Field Name in the Fields list.
13. Custom view ID
Some custom functions operate based on a custom view you've created. To execute the custom function based on the custom view within your portal, you'll need the custom view ID.
To fetch the ID of the Custom View, select the Module where you created the Custom View >> Views >> choose the custom view, right click on the page and select inspect. Click on Network in the Inspect tab. Click clear to clear the Network tab. Click Save on the custom view. In the Network console, the first 16 digit number you see is the Custom view ID. Click on the ID to view the headers, you can confirm the ID here.
To fetch the Custom View ID:
- Navigate to the module where the custom view was created.
- Go to Views and select the desired custom view. Click Edit on the custom view.
- Right-click on the page and select Inspect to open the developer tools. Click the Network tab.Click on Click Clear to empty the Network logs.
- Now, click Save on the Custom View. In the Network console, look for the first 16-digit number—this is the Custom View ID.
- Click on that entry to view the Headers, where you can confirm the ID.
With this episode, we bring the custom function series to a close.
Here are the links to visit the previous episodes:
We’d love to hear how these inputs have helped you! If there are any topics you'd like us to focus on, share them in the comments below.
Until the next post, see you soon!
Lydia | Zoho Desk