Track days of deal inactivity

Automatically calculate and update the number of days a deal record has been inactive based on its last activity in your CRM.

Not every deal receives the attention it deserves. Some may slip through the cracks and get overlooked, despite their potential value. Keeping track of the number of days since the last action on a deal can be beneficial in this context. Based on this duration, you can set up alerts to bring these overlooked deals back into focus. However, you may have noticed in your CRM that there is no straightforward method or ready-made automation to achieve this. Fortunately, our low-code tools can make it possible.

Using a combination of custom fields, a deluge script, and a schedule, you can automatically compute the number of days since the last action on a deal record every day. The daily computation ensures you always see the exact number of inactive days. Read on to learn more.

Permissions and availability

  • Users with the Manage Extensibility permission can create connections and write custom functions.
  • Users with the Modules Customization permission can add custom fields.
  • Users with the Manage Views permission can create custom list views.
  • Users with the Manage Automation permission can create and update schedules.
  • Users with the Manage Sandbox permission can manage the sandbox.

Requirements

  • Create a Zoho OAuth connection with the required scopes for your Zoho CRM account, as detailed in the "Create Connection" section below. Learn more
  • Add a Date and Formula field in the Deals module. These fields will hold the deal's last updated date and duration of inactivity, respectively. Learn more
  • Add a Checkbox field in the Deals module to be updated via the schedule. Learn more
  • Create a custom list view that lists the deal records needing inactivity tracking. Learn more
  • Create a new daily schedule to run at 12:30 AM, and link it to the custom function. Learn more
  • Write a custom Deluge function that automatically updates the checkbox field in deal records from the specified list view. Learn more
  • Test the schedule in a sandbox before deploying it in your production environment. Learn more

Create a connection

The first step is to create an OAuth connection in your Zoho CRM account.

  1. Navigate to Setup > Developer Space > Connections.
  2. Click Create Connection.
  3. Select Zoho OAuth under Default Services.
  4. Specify a Connection Name.
    You will need to enter this name in the code snippet below.
  5. Select the following Scope to request access.
    • ZohoCRM.mass_update.deals.UPDATE
  6. Click Create and Connect.
  7. Click Connect, then click Accept to confirm authorization of access for the scope requested by the client.
Create Connection

Add custom fields

The next step is to add custom date, formula, and checkbox fields to the Deals module.

  1. Navigate to Setup > Customization > Modules and Fields.
  2. Click the Deals module to open the layout editor.
  3. Drag and drop the Date field from the New Fields tray to the layout.
  4. Name the date field (e.g. "Last Updated On") and define its properties as required.
  5. Drag and drop the Formula field from the New Fields tray to the layout.
  6. In the Formula Properties window, do the following:
    1. Enter the Field Label (e.g. "Days Inactive").
    2. Select Decimal as the Formula Return Type from the drop-down list.
    3. Enter 0 as the value for the Number of decimal places.
    4. Copy and paste the following formula into the Formula Expression box.
      Datecomp(Now(),${Deals.Last Updated On})/24/60
    5. Click Check Syntax to verify the construction of the formula.
    6. Click Done.
  7. Drag and drop the Checkbox field from the New Fields tray to the layout.
  8. Name the checkbox field (e.g. "Mass Update") and define its properties as required.
  9. Once you have finished, click Save and Close.

Create a custom list view

The next step is to create a custom list view that lists the deals whose duration of inactivity needs to be auto-updated.

  1. Click the Deals Tab.
  2. In the Deals Home page, move your mouse pointer to the list view's drop-down.
  3. Click the New Custom View link and do the following:
    1. Enter a name for the custom view. (e.g. "Inactive Deals")
    2. Specify the following criteria to filter records.
      <Days Inactive> <is not empty> = ${NOTEMPTY} 
      [AND]
      <Stage> <is OPEN> = ${All Open stages}
    3. Select the columns to be displayed in the view.
    4. Choose who can see this custom view.
  4. Click Save and copy the view's ID from the address bar, which you must enter in the code snippet below.

Create a schedule

The final step is to create a new schedule in your Zoho CRM account.

  1. Navigate to Setup > Automation > Schedules > +Create New Schedule.
  2. Provide a name for the schedule. For example: "Calculate deal inactivity days".
  3. Click Add Description and enter a description if necessary.
  4. In the Function to be executed field, choose Writing Function.
  5. In the Create New Function window, do the following:
    1. Provide a name, display name, and description, if necessary, for the function.
    2. Select Deluge as the Language, then click Create.
  6. In the Deluge Script Editor, do the following:
    1. Copy and paste the code given below.
    2. Click Save.
  7. Choose an Execution Start Date and time for the function to be executed.
  8. Choose the schedule frequency as Every day in the Frequency field.
  9. Click Save on the schedule page.

The code

Code Copied
mp = Map();
mp.put("Mass_Update",true);
inputList = List();
inputList.add(mp);
params = Map();
params.put("data",inputList);
params.put("over_write",true);
params.put("cvid","xxxxx");
info "param : " + params;
response = invokeurl
[
	url :"https://www.zohoapis.com/crm/v6/Deals/actions/mass_update"
	type :POST
	parameters:params.toString()
	connection:"connectionname"
];
info "response : " + response;

Notes

  • Replace "xxxxx" with the ID of the custom list view created in the above section. You can find this numeric ID in the URL of the list view page.
  • Make sure to use the accurate API names for their corresponding fields (e.g., "Mass Update") in the code snippet. Learn more
  • Replace "connectionname" with the name of the connection you specified while creating the connection (see the "Create a connection" section above).
  • The script above is an example of how to automatically calculate and update the number of days a deal record has been inactive by finding the difference between the current date and the last activity date in a field. You can use this code for any other module, such as leads, by modifying the module name and other parameters.

Tip

  • Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.

Test the solution

  1. Once the schedule has been executed, open the deal record to view its duration of inactivity.
    Note: You are only allowed to manually trigger the schedule twice per day.
  2. Check whether the Days Inactive field was updated with the latest figure, and also check the Modified Time stamp to confirm the update via the schedule.

Idea

Looking for another way to keep your formula fields up-to-date? Consider enabling the Automatically refresh formula fields containing the Now() function in real-time option in the formula field property window to run the formula every time you view or manually edit a record. Remember that enabling this option may limit your ability to use the formula field for custom views and filters.


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 PointSchedule
  • EditionEnterprise and above
  • ComplexityHigh
  • Implementation Time60 minutes

Features used in the solution

ConnectionCustom FieldCustom ViewScheduleDeluge ScriptSandbox
Story Image

Looking for a custom solution?

Contact us, we will help enhance your productivity at lightning speed.

SUBMIT REQUEST

Developers: Share your solution with our community!