If you're selling insurance or offering a service-level commitment for a product, you probably have the plan or service contract take effect on the day the deal is closed. This requires updating the deal's closing date as the coverage or SLA start date in a separate custom field for closed won deals. Additionally, you also need to record the end date based on the coverage period entered during the deal's closure. For example, if a term plan is valid for a year, you must enter the coverage end date as 12 months from the start date.
To spare you the effort of doing all this manually, our low-code solution can automate the process, making the workflow more efficient. All you need to do is add the required custom fields to the Deals module, write a function, and add a formula field. For more information, read the sections below.
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 Date field and a Number field in the Deals module. The date field will hold the contract start date, and the number field will hold the contract period in months. Learn more
- Create a workflow rule for the Deals module that triggers when a deal's stage is set as closed-won. Learn more
- Write a custom Deluge function and link it up with the workflow rule. Learn more
- Add a formula field in the Deals module. The formula field will compute the contract end date based on the contract period and start date.
- 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 the custom date and number fields to the Deals module.
- Navigate to Setup > Customization > Modules and Fields.
- Click the Deals module to open the layout editor, and do the following:
- Drag and drop the Date field from the New Fields tray to the layout.
- Name the date field (e.g., "Contract Start Date") and define its properties as required.
- Drag and drop the Number field from the New Fields tray to the layout.
- Name the number field (e.g. "Contract Period") and define its properties as required.
- Once you have finished, click Save and Close.
Create a workflow rule
The next step is to create a workflow rule in your CRM account.
- Navigate to Setup > Workflow Rules > +Create Rule.
- Select Deals from the module dropdown list.
- Provide a name for the rule. For example: "Auto-enter contract start 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 <Stage> is modified to <the value> <Closed Won>".
- Click Next.
- In the Which deals would you like to apply the rule to? section, select All Deals and 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 - Closing Date, name it dealClosingDate, and then click Save.
- Click Save & Execute Script.
- Click Save on the workflow rule page.
The code
mp = Map();
mp.put("Contract_Start_Date",dealClosingDate.toString("yyyy-MM-dd"));
info "mp : " + mp;
update = zoho.crm.updateRecord("Deals",dealId,mp);
info "update : " + update;
Note
- Use the accurate API name of the custom fields in the code snippet (e.g., "Contract Start Date"). Learn more
Add a formula field
The final step is to add a formula field in the Deals module that computes the contract end date based on the contract period and start date.
- Navigate to Setup > Customization > Modules and Fields.
- Click the Deals module to open the layout editor.
- Drag and drop the Formula field from the New Fields tray to the layout.
- In the Formula Properties window, do the following:
- Enter the Field Label (e.g., "Contract End Date").
- Select Date as the Formula Return Type from the dropdown list.
- Copy and paste the following formula into the Formula Expression box.
- Adddate(${Deals.Contract Start Date},${Deals.Contract Period},'MONTH') - Click Check Syntax to verify the construction of the formula.
- Click Done.
- Once you have finished, click Save and Close.
Test the solution
- Navigate to the Deals module.
- Open a deal record to view its details.
- On the Deal Details page, enter the contract period in months and update the stage as Closed Won.
The workflow rule will be triggered. - Check whether the contract start date of the deal is updated with its closing date. Also, check if the contract end date is automatically computed based on the contract period.
Tip
- Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.
Idea
If you want to update the deal closing date as the contract start date in your existing deal records, create a custom view that filters the closed-won deals, then enter the view's ID in the code snippet below and execute it once via a schedule.
loop={1,2,3,4,5};
for each ele in loop
{
resp=zoho.crm.getRecords("Deals",ele,200,{"cvid":xxxxx});
for each rec in resp
{
update=zoho.crm.updateRecord("Deals", rec.get("id"),{"Closing_Date":rec.get("Contract_Start_Date")});
info update;
}
}
- The above code snippet will update a maximum of 1,000 deal records in the custom view. If you need to update more than this number, add more pages to the loop; for example, {1,2,3,4,5,6,7,8,9,10}.
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