Zoho CRM: Client Script Confirmation Box and Popup Mailer

Zoho CRM: Client Script Confirmation Box and Popup Mailer

What?
This is an article just repeating a script from the Zoho Kaizen series allowing a confirmation box (something lacking in Zoho Creator - but that every app outside of Zoho has) as well as a popup to email from CRM with a rich-text interface.

Why?
The use-case here is non-existent. It's more of a play around to see what can be achieved and how much this can be customized. The task I've set for myself is as follows:
  • Trigger if the contact record has a tickbox called "Extra Confidential" ticked/checked=true
  • Popup a confirmation box to proceed or cancel.
  • Popup the email from CRM mailer with the to email address, bcc, subject and message content already populated.

How?
The example from the Kaizen series uses a record with canvas mode applied; but I wanted to try it without a canvas to see if we can have this functionality using the out-of-the-box ZohoCRM.

Client Script Configuration:
  1. Login to ZohoCRM as a system administrator and go to the Setup page (cog icon in the top right next to the profile image)
  2. Under "Developer Hub" go to "Client Script"
  3. Click on "New Script" button (the blue one - not the "Add Script" grey one)
  4. Give the client script a name, I'm calling mine "Extra Confidential"
  5. Keep Category=Module, set Page=Detail Page (Standard), set Module=Contacts and set the layout if you want.
  6. Under Event Details, set Type=Page Event; Event=onLoad
  7. Click on "Next"
  8. Give it the following code:
    copyraw
    // attempt 
    try {
    
        // get the ID of this record 
        var v_ThisRecordID = $Page.record_id;
    
        // get the full name of this contact (not sure why this returns both first and last)
        var v_ContactName = ZDK.Page.getField('Last_Name').getValue();
    
        // get the email of this contact
        var v_ContactEmail = ZDK.Page.getField('Email').getValue();
    
        // get the value of the custom boolean/checkbox field "Extra Confidential"
        var b_ContactConfidential = ZDK.Page.getField('Extra_Confidential').getValue();    
    
        // if this is a sensitive record, ie "Extra Confidential" has been ticked
        if (b_ContactConfidential) {
    
            // prompt with a confirmation box
            var b_Proceed = ZDK.Client.showConfirmation('Do you want to open the mailer window?', 'Proceed', 'Cancel');
    
            // if both "Extra Confidential" is ticked and confirmation was Yes/true then proceed
            if (b_Proceed) {
                ZDK.Client.openMailer({ from: '', to: [{ email: v_ContactEmail, label: v_ContactName }], bcc: [{ email: This email address is being protected from spambots. You need JavaScript enabled to view it.', label: 'Copy for myself' }], subject: 'Greetings from the Joel Lipman team!', body: '<span style=\'font-size:12pt;\'>Hi there!<br /><br />I\'m the very model of a modern major general.<br /><br />Bye.<br /><br />the Team.</span>' });
            }
        }
      
    } catch (e) { 
      
         // return error (don't display it, just show it in the logs) 
        console.log(e); 
         //ZDK.Client.showMessage("Client Script error"); 
    }
    1.  // attempt 
    2.  try { 
    3.   
    4.      // get the ID of this record 
    5.      var v_ThisRecordID = $Page.record_id; 
    6.   
    7.      // get the full name of this contact (not sure why this returns both first and last) 
    8.      var v_ContactName = ZDK.Page.getField('Last_Name').getValue()
    9.   
    10.      // get the email of this contact 
    11.      var v_ContactEmail = ZDK.Page.getField('Email').getValue()
    12.   
    13.      // get the value of the custom boolean/checkbox field "Extra Confidential" 
    14.      var b_ContactConfidential = ZDK.Page.getField('Extra_Confidential').getValue()
    15.   
    16.      // if this is a sensitive record, ie "Extra Confidential" has been ticked 
    17.      if (b_ContactConfidential) { 
    18.   
    19.          // prompt with a confirmation box 
    20.          var b_Proceed = ZDK.Client.showConfirmation('Do you want to open the mailer window?', 'Proceed', 'Cancel')
    21.   
    22.          // if both "Extra Confidential" is ticked and confirmation was Yes/true then proceed 
    23.          if (b_Proceed) { 
    24.              ZDK.Client.openMailer({ from: '', to: [{ email: v_ContactEmail, label: v_ContactName }], bcc: [{ email: This email address is being protected from spambots. You need JavaScript enabled to view it.', label: 'Copy for myself}], subject: 'Greetings from the Joel Lipman team!', body: '<span style=\'font-size:12pt;\'>Hi there!<br /><br />I\'m the very model of a modern major general.<br /><br />Bye.<br /><br />the Team.</span>' })
    25.          } 
    26.      } 
    27.   
    28.  } catch (e) { 
    29.   
    30.       // return error (don't display it, just show it in the logs) 
    31.      console.log(e)
    32.       //ZDK.Client.showMessage("Client Script error")
    33.  } 

Output
  1. Zoho CRM: Client Script Confirmation Box and Popup Mailer: Confirmation Popup
  2. Zoho CRM: Client Script Confirmation Box and Popup Mailer: Email Popup

Source(s):


Category: Zoho :: Article: 867

Please publish modules in offcanvas position.