Hello Everyone,
Welcome to this week's edition, where you can seamlessly sync fields from the Contacts to the Tickets module. For efficient business operations, it's crucial to have details mapped across different modules.
Zylker Secure offers antivirus services with various pricing plans for its customers. Each plan purchased is stored in the Customer module. Every time a customer submitted a query, it was challenging to refer to the plan and process the requirements accordingly. Zylker Secure solved this by mapping pricing plan data from the customer record to the tickets module. This automatic sync streamlined their business operations. Let's see how to implement this automation in your Desk portal.
Prerequisites
1. Create a custom field in the Ticket and Contact layout.
1.1 Go to Setup >> Customization >> Layouts and Fields.
1.2 Choose the required Department and select the Ticket layout under it.
1.3 Create a custom field in the Ticket layout. Click Save.
1.4 In Layouts, choose Contacts from the drop-down list for the same department.
1.5 Click on the Contact layout and create the same custom field type in the Contacts layout.
Click Save.
Note: The field type in the Contacts layout must match the field type in the Tickets layout. For example, if one layout has a single line field, the other must also have a single line field. Similarly, if one has a picklist field, the other must have a matching custom picklist field.
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 the Create checkbox to execute this rule every time a new ticket is created.
8. Click Next.
9. Leave the Criteria blank and click Next.
10. In the Actions section, click the + icon and select New next to Custom Functions.
11. Enter a Name and Description for the custom function.
12. In the script window, insert the Custom Function given below:
- orgId = "6*********0"; // replace orgId
- ticketAPIName = "cf_name"; // replace API name of the custom field in Tickets layout
- contactAPIName = "cf_name"; // replace API name of the custom field in Contacts layout
- getContact = zoho.desk.getRecordById(orgId,"contacts",ContactID);
- customFields = getContact.getJSON("cf");
- updateTicket = zoho.desk.update(orgId,"tickets",TicketID,{"cf":{ticketAPIName:customFields.getJSON(contactAPIName)}});
- info updateTicket;
![](https://static.zohocdn.com/zoho-desk-editor/static/images/file.png)
Note: In line 1, place your OrgId. To access your OrgId, go to Setup >> Developer Space >> API.
In line 2, replace the value with the API name of the custom field created in the Tickets layout.
In line 3, replace the value with the API name of the custom field created in the Contacts layout.
To access API name of the custom field, Go to Setup>>Customization>>Layouts and Fields >> Fields List. Select the module, and you can find the API name of the custom field created.
13. Click Edit Arguments and include the argument mapping as below:
13.1. In the Name field type ContactID, and from the Value drop-down list select Contact Id under Contact Sections.
13.2. In the Name field type TicketID, and from the Value drop-down list select Ticket Id under Ticket Sections.
14. Click Save to save the custom function.
15. Click Save again to save the workflow.
Implementation
When a ticket is created, the custom field in the Tickets layout is updated automatically by fetching the value from the custom field in the Contacts layout.
See you next week with another custom function coming your way!