Qntrl | Online Help | Business case 1: Populate read recipients list for a card using Server Scripts (On Load)

Business case 1: Populate read recipients list for a card using Server Scripts (On Load)

Managers find it useful to know which employees have viewed a new card or comment, like a read receipts list. It helps managers know if an employee has viewed his assigned task and evaluate how informed employees are about new updates in the organization. To customize such requirements in Qntrl, server scripts can be used.
 

Business Scenario

Zylker Corp is making arrangements for a product launch and all the employees are roped in for the process. Every employee is assigned tasks to complete. The managers of the company want to monitor the employees who are actively involved in the launch and keep track of the card.
 

Solution

The requirement can be solved using server scripts as follows:
  1. Create a multi select field-- Read Recipients --in the form with different user names as options.
  2. Create a server script and code the logic to populate users in the Read Recipients field when users open the card.
  3. Create a card and add the work that has to be taken up for the product launch and track the users who have viewed the card using the Read Recipients field.

Sample Configuration

Step 1: Create an orchestration

Create a new orchestration for the product launch and add related fields to it.
  1. Add a multi select field and name it Read Recipients.
  2. Add user names as options to the multi select field.
  3. Turn off the visibility so that the field is hidden while creating a card.


 
Once the form is saved, proceed to design the blueprint, set permissions, and publish the orchestration.
 

Step 2: Code server scripts

Code the server script to populate user names in the Read Recipients field when they open the card.
  1. Create a new server script and enter a name: 'Populate read recipients list'.
  2. Choose Product Launch in the Form dropdown.
  3. Choose Job as the Execution Location to execute the script.
  4. Choose On Load  as the Execution Trigger to execute this script whenever the card page loads.
  5. Copy and paste the below script into your script editor and replace the parameter names.
    1. You can use the ? icon at the top-right corner of the script editor to refer to parameter names.
  6. Once the script is ready, Publish it. 

  1. function onLoad(){
  2.     var userIdPicklistIdMap = {};
  3.     userIdPicklistIdMap["<User_ID>"] = "<Picklist ID>";
  4.     userIdPicklistIdMap["<User_ID>"] = "<Picklist ID>";
  5.     userIdPicklistIdMap["<User_ID>"] = "<Picklist ID>";
  6.     userIdPicklistIdMap["<User_ID>"] = "<Picklist ID>";
  7.     userIdPicklistIdMap["<User_ID>"] = "<Picklist ID>";
  8.  
  9. //Get User ID from our API doc: Get all users
  10. //Get Dropdown ID from our API doc: Get all custom fields
  11.  
  12.     var myPickId = userIdPicklistIdMap[current.User.getId()];
  13.     if (!myPickId) {
  14.         console.log("Current user not available in Read Recipients dropdown"); 
  15.         return;
  16.     }
  17.     var readRecipients = current.Job.getVariable("Read Recipients");
  18.     if (!readRecipients) {
  19.         readRecipients = "";
  20.     }
  21.     console.log("Read recipients = " + readRecipients);
  22.     var splitByComma = readRecipients.split(",");
  23.     if (!splitByComma[0]) {
  24.         splitByComma.shift();
  25.     }
  26.  
  27.     if (splitByComma.indexOf(myPickId) == -1) {
  28.         splitByComma.push(myPickId);
  29.     }
  30.     console.log("result = " + splitByComma.join(","));
  31.     current.Job.setVariable("Read Recipients", splitByComma.join(","));
  32.   
  33. //Select Read Recipients parameter here
  34. current.Job.setValue(current.Layout.Fields.<select-Read-Recipients-parameter-here>.id ,splitByComma.join(","));
  35.     console.log("Read Recipients updated");
  36.  
  37. }


 

Step 3: Add card

When the orchestration and server script are ready, we can test the script by creating a new card.
  1. Navigate to Cards and click Add Card.
  2. Select Product Launch  from the Form dropdown.
  3. Enter the card details and Save.
Once the users start viewing the card details page, their names will start getting populated in the Read Recipients field.




    Access your files securely from anywhere

      Zoho CRM Training Programs

      Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

      Zoho CRM Training
        Redefine the way you work
        with Zoho Workplace

          Zoho DataPrep Personalized Demo

          If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

          Zoho CRM Training

            Create, share, and deliver

            beautiful slides from anywhere.

            Get Started Now


              Zoho Sign now offers specialized one-on-one training for both administrators and developers.

              BOOK A SESSION





                          Quick Links Workflow Automation Data Collection
                          Web Forms Enterprise Begin Data Collection
                          Interactive Forms Workplace Data Collection App
                          CRM Forms Customer Service Accessible Forms
                          Digital Forms Marketing Forms for Small Business
                          HTML Forms Education Forms for Enterprise
                          Contact Forms E-commerce Forms for any business
                          Lead Generation Forms Healthcare Forms for Startups
                          Wordpress Forms Customer onboarding Order Forms for Small Business
                          No Code Forms Construction RSVP tool for holidays
                          Free Forms Travel
                          Prefill Forms Non-Profit

                          Intake Forms Legal
                          Mobile App
                          Form Designer HR
                          Mobile Forms
                          Card Forms Food Offline Forms
                          Assign Forms Photography
                          Mobile Forms Features
                          Translate Forms Real Estate Kiosk in Mobile Forms
                          Electronic Forms

                          Notification Emails for Forms Alternatives Security & Compliance
                          Holiday Forms Google Forms alternative  GDPR
                          Form to PDF Jotform alternative HIPAA Forms
                          Email Forms
                          Encrypted Forms
                          Embeddable Forms
                          Secure Forms
                          Drag and Drop form builder
                          WCAG


                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                Manage your brands on social media

                                                  Zoho Desk Resources

                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                    Zoho Marketing Automation

                                                      Zoho Sheet Resources

                                                       

                                                          Zoho Forms Resources


                                                            Secure your business
                                                            communication with Zoho Mail


                                                            Mail on the move with
                                                            Zoho Mail mobile application

                                                              Stay on top of your schedule
                                                              at all times


                                                              Carry your calendar with you
                                                              Anytime, anywhere




                                                                    Zoho Sign Resources

                                                                      Sign, Paperless!

                                                                      Sign and send business documents on the go!

                                                                      Get Started Now




                                                                              Zoho TeamInbox Resources



                                                                                      Zoho DataPrep Resources



                                                                                        Zoho DataPrep Demo

                                                                                        Get a personalized demo or POC

                                                                                        REGISTER NOW


                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now









                                                                                                                Wherever you are is as good as
                                                                                                                your workplace

                                                                                                                  Resources

                                                                                                                  Videos

                                                                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                  eBooks

                                                                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                  Webinars

                                                                                                                  Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                  CRM Tips

                                                                                                                  Make the most of Zoho CRM with these useful tips.



                                                                                                                    Zoho Show Resources