Hello Everyone!
Welcome back to the Community Learning Series! Today, we explore how Zylker Techfix, a gadget servicing firm, boosted productivity by tracking the time spent at a particular ticket status in Zoho Desk.
Zylker Techfix customized Zoho Desk’s ticket statuses to align with their servicing process. Here’s their workflow: when a gadget was submitted for service, the ticket entered “Open” status. After an initial examination, it moved to “Service” status, mapped to the “Hold” type while repairs were underway. Once repairs were complete, the ticket progressed to “Billing” and then to “Closed” after payment and delivery. To improve operations, Zylker Techfix wanted to know how long tickets stayed in “Service” status, giving them insights into potential delays and resource use. With a custom function, they tracked this time in a custom field, then used it to generate reports that highlighted areas for process improvement.
With this custom function, you can gain a clear view of your support timeline, identify bottlenecks, and serve clients more efficiently. Let’s dive into how you can implement this custom function to refine your own operations and drive productivity forward.
Prerequisites
1. Create a Custom Field
To track ticket duration at a StatusName (call it In progress) mapped to the Status Type On Hold,
1.1 Go to Setup (S) >> Customization >> Layouts and Fields.
Select Tickets under Layouts and the Department in which you would like to track the ticket duration.
1.2 Create a custom single line field in the Tickets layout of the respective department.
1.2.1 Click on the layout, add a single line field with a label StatusTime.
You can label the field with your preferred name.
1.3 Note the API names for the the single line field to insert into the custom function.
To find the API name, Click on the Gear wheel icon of the single line field.
Click on Edit Properties, you will find the API Name under the Edit Field. Refer to Create Custom Fields.
2. Create a connection
2.1 Go to Setup(S) and choose Connections under Developer Space.
2.2 Click Create Connection.
2.3 Select Zoho OAuth under Default Connection.
2.4 Set the connection name as deskconnection.
2.5 Under Scope, choose the below scope values:
Desk.tickets.READ
Desk.tickets.UPDATE
2.6 Click Create and Connect.
2.7 Click Connect and click Accept.
Connection is created successfully.
Create a Workflow Rule
1. Go to Setup, choose Workflows under Automation.
2. Under Workflows, click Rules >> Create Rule.
In the Basic Information section,
3. Select Tickets from the drop-down menu under Module.
4. Enter a Rule Name and Description for the rule.
5. If you want to activate the rule right away, select the Active checkbox. Else, create the rule and activate it later.
6. Click Next.
In the Execute on section, follow these steps:
7. Select Field Update, Choose Status.
8. Click Next.
9. Leave the Criteria section blank and click Next. (Add a criteria if you require it.)
10. In the Actions section, click the + icon and select New next to Custom Functions.
12. Enter a Name and Description for the custom function.
13. In the script window, insert the Custom Function given below:
- ///----<<<< User Inputs >>>>----
- deskURL = "https://desk.zoho.com";
- //Replace with your custom domain
- //Replace your Custom Field API Name to Update Desired Type Status Duration Ex: Open
- durationApiName = "cf_status_name";
- // ex: "cf_open_time"
- //Replace your Desired Status Type Name Ex: Open
- statusType = "On Hold";
- // Open or On Hold or Closed
- //Replace the Status Name
- statusName = "In Progress";
- // Ex: In Progress, Waiting for Reply, etc
- // ----<<<< Initial Configs >>>>----
- logs = Map();
- logs.insert("ticketId":ticketId);
- openHoursToUpdate = 0;
- openMinutesToUpdate = 0;
- onHoldHoursToUpdate = 0;
- onHoldMinutesToUpdate = 0;
- //---------------------------
- try
- {
- // ---- start your logic from here ----
- ticketStatusLifeCycleInfo = invokeurl
- [
- url :deskURL + "/api/v1/tickets/" + ticketId + "/statusLifeCycle"
- type :GET
- connection:"deskconnection"
- ];
- logs.insert("ticketStatusLifeCycleInfo":ticketStatusLifeCycleInfo);
- if(ticketStatusLifeCycleInfo != null && ticketStatusLifeCycleInfo.containsKey("statusLifeCycle") && ticketStatusLifeCycleInfo.get("statusLifeCycle").size() > 0)
- {
- for each statusInfo in ticketStatusLifeCycleInfo.get("statusLifeCycle")
- {
- statusType = statusInfo.get("statusType");
- statusName = statusInfo.get("status");
- if(statusType == statusType && statusName == statusName)
- {
- statusDuration = statusInfo.get("duration");
- if(statusDuration != null && statusDuration != "")
- {
- statusDuration = statusDuration.replaceAll(" hrs","");
- durationCollection = statusDuration.toCollection(":");
- hourDuration = durationCollection.get(0);
- minuteDuration = durationCollection.get(1);
- openHoursToUpdate = openHoursToUpdate + hourDuration.toNumber();
- openMinutesToUpdate = openMinutesToUpdate + minuteDuration.toNumber();
- }
- }
- }
- openHoursToUpdate = (openMinutesToUpdate / 60).toNumber() + openHoursToUpdate;
- openMinutesToUpdate = openMinutesToUpdate % 60;
- logs.insert("openHoursToUpdate":openHoursToUpdate);
- logs.insert("openMinutesToUpdate":openMinutesToUpdate);
- ticketUpdateParams = Map();
- ticketUpdateParams.insert("cf":{durationApiName:openHoursToUpdate + ":" + openMinutesToUpdate});
- logs.insert("ticketUpdateParams":ticketUpdateParams);
- ticketUpdate = invokeurl
- [
- url :deskURL + "/api/v1/tickets/" + ticketId
- type :PUT
- parameters:ticketUpdateParams + ""
- connection:"deskconnection"
- ];
- logs.insert("ticketUpdate":ticketUpdate);
- }
- }
- catch (errorInfo)
- {
- logs.insert("errorInfo":errorInfo);
- }
- info "logs: \n" + logs; logs.insert("errorInfo":errorInfo);
- }
- info "logs: \n" + logs;
NOTE
a. In Line 2, Replace ".com" with the domain extension based on your Data Center.
b. In Line 5, add the API name of the custom field created within the Tickets layout.
c. In Line 8 and line 11, enter the status type and status name.
14. Click Edit Arguments and include the argument mapping as below:
14.1 In the Name field, type ticketId and from the Value drop-down list, select Ticket Id under the Tickets Section.
15. Click Save to save the custom function.
16. Click Save again to save the workflow.
Creating Ticket Tracking Reports
You can generate Reports under Analytics to view the time duration of your tickets in one go.
Go to the Analytics module >> Choose Reports >> Add Report >> Select Tickets module and Time Entry under Related modules. Refer to Create Custom Report
Let us know how this custom helps improve your ticketing process.
Until next week,
Warm regards,
Lydia | Zoho Desk