Zoho Desk - Sync fields between contact module and ticket module

Zoho Desk - Sync fields between contact module and ticket module

Just helping the community by sharing a custom script that we implement. Always open to other ways to achieve this more efficiently.


Objective: I have different types of customers (I,E Vendor, Reseller, End-User),
  1. I want to record what type of customer they are when the customer logs a ticket.
  2. Store this data field against the Contact record
  3. Show this record on the ticket without having to have the agent open up the contact record
  4. Force the agent to update the Customer type field before allowing them to close the ticket
  5. If the customer logs any future tickets, those tickets will show the customer's type
Challenge: We can create custom fields on a ticket level and have them as required fields. But this data set belongs to the Contact record and not the Ticket record

Solution:

Part 1, Create the custom fields in the Contact Module
  1. Go to Customisation > Layouts and fields > Contacts
  2. Create a new field called Contact Type
  3. Note the API Name. In my case, it was called cf_contact_type
  4. I also set this to be a required field if we create the customer contact directly
Contact Module
Part 2, Create the custom fields in the Ticket Module
  1. Go to Customisation > Layouts and fields > Tickets
  2. Create a new field called Contact Type
  3. Note the API Name. In my case, it was called cf_contact_type
  4. I also set this to be a required field if we create the ticket directly
Ticket Module


We now have a drop-down list called Contact Type in both Tickets and Contacts.
But we need to keep them in sync. We do this in a Workflow

Part 3, Create a workflow to update the Contact Type in the Contacts module when the Contact Type in the Ticket Module is updated.

Create a new Workflow in Automation > Workflows


  1. Module: Tickets
  2. Rule Name: 1.A Ticket to contact module sync for Contact Type
  3. Description: Updating the contact type on a ticket record will update the person record
  4. Execute on: Field Update: Contact Type (This is the new Custom field you created)
  5. Criteria: N/A
  6. Action: Custom Function: Create a new and give it a name (Ticket to Contact sync)



Paste in the following code and substitute with your OrgId and DeskURL

substitute the contactCfApiName and ticketCfApiName if you changed it above
  1. OrgId = xxxxxxxxxx;
  2. deskUrl = "https://xxxxxxxxxx.com";
  3. contactCfApiName = "cf_contact_type";
  4. ticketCfApiName = "cf_contact_type";
  5. connection = "zohodesk";
  6. updateContact = invokeurl
  7. [
  8. url :deskUrl + "/api/v1/contacts/" + contactId
  9. type :PATCH
  10. parameters:{"cf":{contactCfApiName:ticketCfValue}} + ""
  11. connection:connection
  12. ];
  13. info updateContact;
1.A Function

Click on Edit Arguments and set the following Argument Names to these values
  1. contactId > Contact Id
  2. ticketId > Ticket Id
  3. ticketCfValue > Contact Type
  4. contactCfValue > Contact Type
Arguments

We now are updating the Contact Type in the Contacts module when the Contact Type in the Ticket Module is updated.
But we want to have any new tickets created from that customer pull in the Contact Type from the Contact Module into any new Ticket we create

Part 4, Create a workflow so that any new ticket created will auto-populate the Contact Type in the Ticket module from the Contact Module

Create a new Workflow in Automation > Workflows


  1. Module: Tickets
  2. Rule Name: 1.B Apply contact type value for all new tickets 
  3. Description: New ticket comes in, check person record if "customer type" is set and then copy it to the ticket
  4. Execute on: Create
  5. Criteria: N/A
  6. Action: Custom Function: Create a new and give it a name (

    Apply contact type value for all new tickets

    )
1.B Workflow

Paste in the following code and substitute with your OrgId and DeskURL

substitute the contactCfApiName and ticketCfApiName if you changed it above
  1. OrgId = xxxxxxxxxx;
  2. deskUrl = "https://xxxxxxxxxx.com";
  3. contactCfApiName = "cf_contact_type";
  4. ticketCfApiName = "cf_contact_type";
  5. connection = "zohodesk";
  6. if(contactCfValue != null && contactCfValue != "")
  7. {
  8. updateTicket = invokeurl
  9. [
  10. url :deskUrl + "/api/v1/tickets/" + ticketId
  11. type :PATCH
  12. parameters:{"cf":{ticketCfApiName:contactCfValue}} + ""
  13. headers:{"featureFlags":"skipAutomations"}
  14. connection:connection
  15. ];
  16. info updateTicket;
  17. }
1.B Function
Click on Edit Arguments and set the following Argument Names to these values
  1. contactId > Contact Id
  2. ticketId > Ticket Id
  3. ticketCfValue > Contact Type
  4. contactCfValue > Contact Type
Arguements
End result


When a customer logs a ticket, it will first look at their contact Record and see if the customer field Contact Type is set. If it is it will copy that to the Ticket record and display it.
If it is not set, making a change in the Ticket record will update the Contact Record

If you want to force your agents to fill in this field before they close the ticket. You can setup a Blueprint that during the transition Contact Type must be set

It looks like this



    Zoho Desk Resources

    • Desk Community Learning Series


    • Digest


    • Functions


    • Meetups


    • Kbase


    • Resources


    • Glossary


    • Desk Marketplace


    • MVP Corner


    • Word of the Day


      • Sticky Posts

      • Live Webinar - Work smarter with Zoho Desk and Zoho Workplace integration

        Hello customers! Zoho Desk and Zoho Workplace are coming together for a webinar on 14th May, 2024. Zoho Workplace is a suite of productivity apps for email, chat, docs, calls, and more at one single place. Zoho Desk is closely integrated with a few tools
      • Apple iOS 17 and iPadOS 17 updates for Zoho Desk users

        Hello Zoho Desk users! Apple recently announced the release of iOS 17 and iPad OS 17. These latest OS updates will help you stay productive and efficient, through interactive and seamless user experiences. Zoho Desk has incorporated the updates to help
      • Zoho Desk Partners with Microsoft's M365 Copilot for seamless customer service experiences

        Hello Zoho Desk users, We are happy to announce that Zoho Desk has partnered with Microsoft's M365 to empower customer service teams with enhanced capabilities and seamless experiences for agents. Microsoft announced their partnership during their keynote
      • Zoho Desk Cheat Sheet For The Year-End

        Check out these Zoho Desk best practices to end this year on a high and have a great one ahead! #1 Set Business (Holiday) Hours - If you have limited working hours, please make sure you restrict your business hours or set them as holidays for the coming days. Let your customers know when you will, and won't, be available. #2 Update the Annual Holiday List - Check the holidays for the new year and update the holiday schedule. Usually, holidays from the current year will be carried over for the next
      • Deprecation of older versions of ASAP Mobile SDK | Zoho Desk

        Hello, everyone.    Greetings from Zoho Desk ASAP!   In order to continue to deliver the best and most secure experience to our mobile SDK users. On account of the recent enhancements and updates to the mobile SDKs, we have planned to mark the older versions

      Zoho CRM Plus Resources

        Zoho Books Resources


          Zoho Subscriptions Resources

            Zoho Projects Resources


              Zoho Sprints Resources


                Zoho Orchestly Resources


                  Zoho Creator Resources


                    Zoho WorkDrive Resources



                      Zoho Campaigns Resources

                        Zoho CRM Resources

                        • CRM Community Learning Series

                          CRM Community Learning Series


                        • Tips

                          Tips

                        • Functions

                          Functions

                        • Meetups

                          Meetups

                        • Kbase

                          Kbase

                        • Resources

                          Resources

                        • Digest

                          Digest

                        • CRM Marketplace

                          CRM Marketplace

                        • MVP Corner

                          MVP Corner




                          Zoho Writer Writer

                          Get Started. Write Away!

                          Writer is a powerful online word processor, designed for collaborative work.

                            Zoho CRM コンテンツ




                              ご検討中の方