A deal closing date is when a sales deal is expected to be finalized. This date is subject to change until the deal is marked as closed won, as it may get extended due to unforeseen delays in the sales process, alterations in customer requirements, additional negotiations, or other factors. However, keeping track of the number of times a deal's closing date has been updated can help with better decision-making and more effective deal management in the future. Unfortunately, the current CRM version does not support tracking this count, and the existing workflow automation can only update a specific number in a field and cannot increment its value. This is where a custom function can be beneficial.
A custom function can help you track and record how often a specific action has occurred in a deal record. To achieve this, you first need to create a workflow rule for the deals module that updates the count in a custom field every time its closing date gets updated. 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 a Number field in the Deals module. This field will hold the number of times the closing date is updated. Learn more
- Create a workflow rule for the Deals module that triggers every time the closing date is updated. Learn more
- Write a custom Deluge function and link it with the workflow rule to update the count in the custom number field. Learn more
- Test the workflow rule in a sandbox before deploying it to your production environment. Learn more
Add a custom field
The first step is adding the custom Number field to the Deals module.
- Navigate to Setup > Customization > Modules and Fields.
- Click the Deals module to open the layout editor.
- Drag and drop the Number field from the New Fields tray to the layout.
- Name the number field (e.g., "Times Close Updated") and define its properties as required.
- Once you have finished, click Save and Close.
Create a workflow rule
Next, you need to write and connect a custom function with a workflow rule.
- Navigate to Setup > Workflow Rules > +Create Rule.
- Select Deals from the module dropdown list.
- Provide a name for the rule. For example: "Record changes to deal closing date".
- Add a description (optional), 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.
- Choose Specific field(s) gets modified from the dropdown, then enter the condition "When <Closing Date> is modified to <any value>".
- 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.
- On the Deluge Script Editor, do the following:
- Copy and paste the code provided below.
- Click Edit Arguments.
- Choose Deals - Deal Id, then name it dealId.
- Click the + icon to add more arguments.
- Choose Deals - Times Close Updated and name it oldcount, and then click Save.
- Click Save & Execute Script.
- Click Save on the workflow rule page.
The code
mp=map();
if(oldcount==null)
{
oldcount = 0;
}
mp.put("Times_Close_Updated",oldcount+ 1 );
update = zoho.crm.updateRecord("Deals", dealId.toLong(), mp);
info mp;
info update;
Notes
- Use the accurate API name of the custom URL field in the code snippet (e.g., "Times Close Updated"). Learn more
- The code above is an example of how to record and track the number of times your salespeople update the closing date of a deal on a custom field. You can use this code to track actions for any other field or module, such as leads or custom, by modifying the module name and parameters.
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Click the Deals tab.
- Open the deal record whose closing date must be updated.
- Update the closing date to a date in the future and click Save.
The workflow rule will be triggered. - Check whether the Times Close Updated field was updated with the count of one, confirming the date update.
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