Send automatic updates on deal progression by stage to all the Contact Roles

Business scenario

The Deals module in Zoho CRM is designed to associate only one Contact per deal. Very often, B2B sales require touching upon multiple stakeholders, and the person you engage with need not be the decision maker. It is essential to keep track of all the contacts related to a deal. The Contact Roles field, listed under the Related List in deals module helps you do just that. It lets you profile multiple buyers associated with the deal based on their level of influence - Decision maker, Evaluator, Executive Sponsor, etc.

Part of the process while dealing with multiple buyers is sending updates on deal progression. The Executive Sponsor might be interested in the Price Quote. The evaluator might be interested to know whether deal is won. What if you want to update all the buyer profiles listed in the Contact Roles on deal progression. Getting all the email addresses from CRM and sending an email from your email client is indeed laborious. This week's function helps you automate this requirement by sending emails to all the related contacts about deal progress in a jiffy. However, as this function links to workflow with a canned message related to the deal status, it is required to replicate this multiple times based on the deal stages that require email notification. The required steps are detailed below:

Getting started with the function

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Update Deal Progression".
  3. Select the module to be associated as Deals. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit Arguments".
  6. Enter the name as "dealId" and select the value as "Deal Id".
  7. Enter the name as "phone" and select the value as "Phone".
  8. Click Save & Execute Script.
  9. Save the changes.
 

The Code


relatedcontroles = zoho.crm.getRelatedRecords("Contact_Roles", "Deals", input.dealId.toLong()); 
//info relatedcontroles; 
potIdStr=input.potId.toString(); 
potentialDetails = zoho.crm.getRecordById("Deals",input.dealId); 
name=ifnull(potentialDetails.get("Deal_Name"),""); 
closedate=ifnull(potentialDetails.get("Closing_Date"),""); 
closetime=ifnull(potentialDetails.get("Closing _Time"),"5:00"); 
closelocation=ifnull(potentialDetails.get("Closing_Location"),"chennai"); 
for each role in relatedcontroles 
{ 
emailAddress= role.get("Email"); 
info emailAddress; 
str="<p>Hello all,<br /><br />Just wanted to make sure everyone hear the great news... the closing for " + name + " has been scheduled.<br />Date: " + closedate + " <br />Time: " + closetime + "<br />Location: " + closelocation + "<br /><br />Sincerely,<br />Gregory Pfeiffer .</p>"; 
sendmail 
[ 
from:zoho.adminuserid 
to:emailAddress 
subject:"Closing Scheduled" 
message:str 
content type:HTML 
] 
}

Note:

  • The above code is written to update on closed deals. You may change the parameters 'closedate, closetime and closelocation', subject and the content of the email to customize it for other deal stages.

Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips