In deal management, timely communication with all stakeholders becomes essential once a closing date is confirmed. At the closing stage, everyone associated with the deal via Contact Roles—such as buyers, sellers, attorneys, co-signers, and other involved parties—must be notified of the closing date, time, and location.
However, manually sending emails to every associated contact can be both time-consuming and error-prone, increasing the risk of leaving key stakeholders uninformed. Such missed notifications can lead to delayed closings, strained client relationships, and even compliance issues. What if your CRM could automatically notify all relevant contact roles when a deal is scheduled to close? This is where a custom function can make all the difference!
A workflow rule powered by a custom function can help you quickly send a deal-closing notification to all contact roles associated with a deal when a sales rep updates the deal stage to a specific value (for example, Closing Scheduled). This HTML notification email, professionally formatted and containing key closing details for each stakeholder, will ensure consistent and timely communication with no manual effort required. Interested? Read on to learn more.
Permissions and availability
- Users with the Modules Customization permission can add custom fields.
- Users with the Manage Automation permission can create and update workflow rules.
- Users with the Manage Extensibility permission can create custom functions.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Add two custom single-line fields to the Deals module. These fields will store a deal's closing time and location. Learn more
- Create a workflow rule for the Deals module that triggers whenever a stage indicating a scheduled deal closure is updated. Learn more
- Write a custom Deluge function that sends email notifications to all deal stakeholders, and link it to the workflow rule. Learn more
- Test the workflow rule in a sandbox before deploying it to your production environment. Learn more
Add custom fields
The first step is to add two single-line fields to the Deals module.
- Navigate to Setup > Customization > Modules and Fields.
- Click the Deals module to open the layout editor.
- In the layout editor, do the following:
- Drag and drop the first single-line field, name it (e.g., "Closing Time"), define its properties, and click Done.
- Drag and drop the second single-line field, name it (e.g., "Closing Location"), define its properties, and click Done.
- Once you've finished, click Save and Close.
Create a workflow rule
Next, create a workflow rule and connect it with a custom function.
- Navigate to Setup > Workflow Rules > + Create Rule.
- Select Deals from the module dropdown list.
- Provide a name for the rule. For example, "Notify stakeholders when closing is scheduled".
- Add a description, if required, then click Next.
- In the Execute this workflow rule based on section, do the following:
- Choose Record Action, then select Edit from the dropdown.
- Check the box for Repeat this workflow whenever a deal is edited option.
- Choose Specific field(s) gets modified from the dropdown, then enter the condition "When <Stage> is modified to <the value> <Closing Scheduled>".
- Click Next.
- In the Which deals would you like to apply the rule to? section, select All Deals, then click Next.
- Under Instant Actions, select Function and Write your own.
- Provide a name for the function, as well as a description, if necessary.
- In the Deluge Script Editor, do the following:
- Copy and paste the code provided below.
- Click Edit Arguments.
- Enter the name as dealId, select the value as Deals - Deal Id, and click Save.
- Click Save & Execute Script.
- Click Save on the workflow rule page.
The code
relatedcontroles = zoho.crm.getRelatedRecords("Contact_Roles","Deals",input.dealId.toLong());
//info relatedcontroles;
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"),"");
closelocation = ifnull(potentialDetails.get("Closing_Location"),"");
for each role in relatedcontroles
{
emailAddress = role.get("Email");
info emailAddress;
str = "<p>Hello all,<br /><br />Hope you are doing well. I wanted to share some great news. The closing for " + name + " has been scheduled.<br />Date: " + closedate + " <br />Time: " + closetime + "<br />Location: " + closelocation + "<br /><br />Sincerely,<br />John Doe</p>";
sendmail
[
from :zoho.loginuserid
to :emailAddress
subject :"Deal closure scheduled"
message :str
content type :HTML
]
}Notes
- Make sure to use the accurate API names for their corresponding fields (e.g., "Closing Time") in the code snippet. Learn more
- The sendmail task uses the logged-in user's email (zoho.loginuserid) as the sender.
- The code above demonstrates how to automatically notify all deal stakeholders about a scheduled deal closure when a deal reaches a specific stage. You can adapt this code for other stages or modules by modifying the module name, stage value, and parameters.
Tip
- Configure and test the solution in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Click the Deals tab.
- Open an existing deal record or create a new one.
- Ensure the deal has at least one contact associated under the Contact Roles related list.
- Populate the Closing Date, Closing Time, and Closing Location fields in the deal record.
- Update the Stage field to "Closing Scheduled" and click Save.
The workflow rule will be triggered. - Verify that each contact listed under Contact Roles received the closing notification email with the correct deal name, closing date, time, and location.
Did you find this useful? Try it out and let us know how it works. Share this with your team if they'd benefit from it! If you have questions, please don't hesitate to contact us.
More info
- ModuleDeals
- Trigger PointWorkflow Rule
- EditionEnterprise and above
- ComplexityMedium
- Implementation Time30 minutes

Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST