Client Script for tags

Client Script for tags



Hello everyone!

Welcome to another informative Kaizen post. In this post, let us see how to accomplish the following using Client Script.

1.  How to auto-tag a record based on field update?

2. How to Open a pre-filled email draft 

This post will provide a quicker solution using Client Script for the queries mentioned in the posts Is it possible to auto fill email draft? and How to tag quickly?

In this Kaizen post,



  1. Tags in Zoho CRM
  2. ZDK functions related to Tags
  3. Use Case 
  4. Solution
  5. Summary
  6. Related Links



1. Tags in Zoho CRM

Tags in Zoho CRM are not just a simple category; they can be more powerful since you can add multiple tags to a single record. You can also create tags in multiple locations in your CRM account, if required. Click here to know more about working with tags.
2. ZDK Functions related to Tags

Below are the ZDK Client APIs supported by Client Script related to tags. Click here to view the documentation.
  • addTag()  - Add a tag/tags to a record
  • removeTag() - Remove a tag/tags to a record
  • getTags() - Get the list of all tags of a record

Notes
Note :
 These ZDKs can be used only for Detail Page(Canvas) and Detail Page(Standard)

Apart from these, you can use the below ZDK CRM APIs to add and remove tags.
  • addTagsToRecord()         - Add Tags to Record
  • addTagsToRecords()       - Add Tags to Record
  • removeTagsToRecord()  -  Remove Tags from Record
  • removeTagsToRecords() - Remove Tags from Records

Notes
Note
The above ZDKs implicitly invoke the Add tags API and Remove tags API. Click here for more details.The execution of the above ZDKs will impact your API credits

To know more about Client Script's ZDKs to implicitly invoke CRM APIs, check this kaizen post. The event onTagChanged - This event occurs on the click of save button of Add tags.

3. Use Case 

Quote
At Zylker, the manager seeks to optimize the handling of order complaints by automating the tagging and notification process. When a customer support agent who places an order on behalf of customers also logs a complaint in the "Order Issue" field of the Orders module, then the order should automatically be tagged as "Issue Reported." This action should open an email draft, pre-filled with a specific template , along with the "To," "From," and "Subject" fields automatically populated after getting confirmation from the customer support agent, and notify the delivery team to check and resolve the issue.

4. Solution

For the above requirement, you need to create a Client Script that triggers when the customer support agent updates the Order issue field.
  • Configure a Client Script for Detail Page(Standard) Orders module, that triggers during onBeforeUpdate Event of Type Field event of Order Issue, as shown below and click Next



  • Click here to know how to configure a Client Script.
  • Enter the following script in the IDE and click Save.

  1. if (value != null) {
  2.    ZDK.Page.addTag('Issue Reported');
  3.    ZDK.Client.showConfirmation('The Tag *Issue Reported* has been added successfully.    Do you want to notify support team?', 'Yes', 'No');
  4.     ZDK.Client.openMailer({ from: 'support@zylker.com', to: [{ email: 'zylker@zyldomain.com', label: 'zylker@zyldomain.com' }], cc: [{ email: 'info@zyldomain.com', label: 'info@zyldomain.com' }], subject: 'Issue Reported', body: '', templateId: "4967860000006521006" });
  5. }
  • In the above script, whenever the customer support agent updates comments in this field, a new tag gets added by ZDK.Page.addTag(). Here is the syntax:


  • Once the tag gets added, a message gets displayed using the ZDK.client.showConfirmation(). The message mentioned in the confirmation box supports markdown. Based on confirmation, the mail draft opens using ZDK.Client.openMailer(). Here is the syntax:


  • Here, you need to specify the template ID of the email in the openMailer() ZDK along with the other details like from, to , cc. 
  • To get the template ID, go to setup-->templates-->select the template that you want and click edit.
  • You can pick the template ID from the URL.


  • Click here to know more about email templates. Here is how the Client Script works.


    Summary

    In this post, we have seen
  • How to add a tag automatically to a record when a Detail Page is updated.
  • How to fetch the tags associated with a record using Client Script.
  • How to open pre-filled email draft from Detail Page(Standard)
  • How to fetch the template id of an email

Related Links: 

Let us know your thoughts in the comment section or reach out to us at support@zohocrm.com. Stay tuned for more insights in our upcoming Kaizen posts!


Happy Client Scripting!


    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now