Prerequisites
1. Create Custom Fields
To track tickets moved from one Department (call it Dep A) to the other Department (call it Dep B) or vice versa,
1.1 Go to Setup (S) >> Customization >> Layouts and Fields. Select Time Entry under Layouts and the Department (let's say Dep B) to which you would like to move the ticket.
1.2 Create three custom single line fields in the Time Entry layout of the respective department (Dep B) . Click on the layout,
1.3 Note the API names for the the single line fields 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. If you would like move the ticket from Dep B to Dep A, create the similar fields in the time entry layout for Dep A. 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 ticket_time_entry_add.
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(S), choose Workflows under Automation.
2. In Workflow Rules, select the Department (Dep B) to which you want to move the tickets.
3. Under Workflows, click Rules >> Create Rule.
In the Basic Information section,
4. Select Tickets from the drop-down menu under Module.
5. Enter a Rule Name and Description for the rule.
6. If you want to activate the rule right away, select the Active checkbox. Else, create the rule and activate it later.
7. Click Next.
In the Execute on section, follow these steps:
8. Select Create.
9. Click Next.
10. Leave the Criteria section blank and click Next.
11. 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 Input -------------
fromDepartmentFieldAPIName = "cf_from_department";
toDepartmentFieldAPIName = "cf_to_department";
agentAPIName = "cf_agent_name";
//----------- Configuration ------------------
logs = Collection();
timeEntryParam = Map();
cf = Map();
historyParam = Map();
historyParam.put("from",0);
historyParam.put("limit",1);
historyParam.put("fieldName","departmentId");
ticketHistory = invokeurl
[
url :deskURL + "/api/v1/tickets/" + ticketId + "/History"
type :GET
parameters:historyParam
connection:"ticket_time_entry_add"
];
logs.insert("ticketHistory":ticketHistory);
if(ticketHistory != null && ticketHistory.get("data") != null)
{
historyDetails = ticketHistory.get("data").get("0");
logs.insert("historyDetails":historyDetails);
if(historyDetails.get("eventName") == "TicketUpdated" && historyDetails.get("eventInfo").get(0).get("propertyName") == "Department")
{
departmentDetailsChanges = historyDetails.get("eventInfo").get("0").get("propertyValue");
previousDepartment = departmentDetailsChanges.get("previousValue").get("name");
currentDepartment = departmentDetailsChanges.get("updatedValue").get("name");
agent = historyDetails.get("actor").get("name");
departmentChangedTime = historyDetails.get("eventTime");
cf.put(fromDepartmentFieldAPIName,previousDepartment);
cf.put(toDepartmentFieldAPIName,currentDepartment);
cf.put(agentAPIName,agent);
timeEntryParam.put("executedTime",departmentChangedTime);
timeEntryParam.put("cf",cf);
logs.insert("timeEntryParam":timeEntryParam);
createTimeEntry = invokeurl
[
url :deskURL + "/api/v1/tickets/" + ticketId + "/timeEntry"
type :POST
parameters:timeEntryParam.toString()
connection:"ticket_time_entry_add"
];
logs.insert("createTimeEntry":createTimeEntry);
}
}
info logs;
NOTE
a. In Line 2, Replace ".com" with the domain extension based on your Data Center.
b. In Line 3, add the API name of the From Department created in the Time Entry Layout.
c. In Line 4, add the API name of the To Department created in the Time Entry Layout.
d. In Line 5, add the API name of the Agent Name created in the Time Entry Layout.
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.
If you would like to move the ticket from Dep B to Dep A, create the workflow rule in Dep A as well.
Creating Ticket Tracking Reports
To track the ticket moved from one department, you can generate Reports under Analytics.
Go to the Analytics module >> Choose Reports >> Add Report >> Select Tickets module and Time Entry under Related modules. Refer to Create Custom Report. This custom function will help you keep an eye on your ticket movements, ensuring that none of your important tickets go missing!
Wishing you a delightful Halloween filled with joy and treats, along with a wonderful fall season! 🎃🍂
Until next week,
Warm regards,
Lydia Kiruba | Zoho Desk