Notify salespeople of new leads

Notify salespeople of new lead assignments via email—either the same day or the next day, depending on their creation times in your CRM.

Does your business commit to contacting new leads within a specific timeframe? Do you want to qualify them quickly to determine if they're a good fit for your business? Or are you looking to engage prospects while their interest is still fresh? Regardless of your case, without a reliable notification system, leads can easily be overlooked and left untouched.

You might consider using the email notification feature in workflows to notify salespeople when they're assigned leads. Or—if you want something even more effective—you could notify salespeople of new lead assignments via email on either the same day or the following business day, depending on when those leads were created and assigned.

For example, if a new lead comes in before 4:00 PM, you can set the system to notify their owners at exactly 4:00 PM the same day. If the lead arrives after 4:00 PM, they'll get the alert at 11:00 AM the next business day. The built-in automation tools can't manage this type of notification flexibility—but, fortunately, custom functions can.

In such circumstances, you can use our low-code tools to send email notifications automatically. Using a combination of a custom field, a Deluge script, and workflow rules, you can automatically notify salespeople of new lead assignments based on their creation times in your CRM.

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 custom Date/Time field to the Leads module. This field will hold the date and time of the lead's creation. Learn more
  • Create a workflow rule for the Leads module that triggers when leads reach a specific stage. Learn more
  • Write a custom Deluge function and link it to the workflow rule to update the creation time in the corresponding leads. Learn more
  • Create another workflow rule for the Leads module that sends email notifications based on the value of the date/time 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 involves adding the custom Date/Time field to the Leads module.

  1. Navigate to Setup > Customization > Modules and Fields.
  2. Click the Leads module to open the layout editor.
  3. Drag and drop the Date/Time field from the New Fields tray to the desired section of the layout.
  4. Name the date/time field (e.g. ""Lead Assignment Time") and define its properties as required.
  5. Once you have finished, select Done, then click Save and Close.

Create a workflow rule

Next, you need to create a workflow rule that triggers when leads reach a specific stage.

  1. Navigate to Setup > Workflow Rules > +Create Rule.
  2. Select Leads from the module dropdown list.
  3. Provide a name for the rule. For example: "Update Lead Creation Time".
  4. Add a description (optional) and then click Next.
  5. In the Execute this workflow rule based on section, do the following:
    1. Choose Record Action, then select Edit from the dropdown.
    2. Check the box for Repeat this workflow whenever a lead is edited option.
    3. Choose Specific field(s) gets modified from the dropdown, then enter the condition "When <Lead Status> is modified to <the value> <New Lead>".
      Note: Choose the status that indicates a lead that is both new and assigned.
    4. Click Next.
  6. In the Which leads would you like to apply the rule to? section, select All Leads, then click Next.
  7. Under Instant Actions, select Function and Write your own.
  8. Provide a name for the function, as well as a description, if necessary.
  9. In the Deluge Script Editor, do the following:
    1. Copy and paste the code given below.
    2. Click Edit Arguments.
    3. Choose Leads - Lead Id, name it lid, and then click Save.
    4. Click Save & Execute script.
  10. Click Save on the workflow rule page.

The code

Code Copied
rec = zoho.crm.getRecordById("Leads",lid);
info rec;
datr = rec.get("Created_Time");
new = datr.remove("-12:00").replaceALL("T"," ").getHour();
info new;
if(new <= 16)
{
	new = today.toDate();
	lol = new.toString("yyyy-MM-dd") + "T16:00:00+05:30";
	update = zoho.crm.updateRecord("Leads",lid,{"xxxxx":lol});
	info update;
}
if(new > 16)
{
	newt = today.toDate().addBusinessDay(1);
	lod = newt.toString("yyyy-MM-dd") + "T11:00:00+05:30";
	updated = zoho.crm.updateRecord("Leads",lid,{"xxxxx":lod});
	info updated;
}

Notes

  • Use the accurate API name of the custom date/time field in the code snippet (e.g., "Lead Assignment Time"). Learn more
  • The function does not consider when a lead is assigned to an owner, so it's recommended to assign leads to salespeople during their creation or immediately afterwards. You can use an assignment rule or workflow rule to automatically assign leads to users based on specified criteria.
  • You can customize the code snippet to notify salespeople at any time your business prefers.
  • The code above is an example of notifying salespeople of new lead assignments via email, either on the same day or the next day, depending on the creation time of the leads in your CRM. You can use this code for any other module, such as Deals or custom modules, by modifying the module name and parameters.

Create a workflow rule to send notifications

Next, create another workflow rule to send email notifications to leads based on the value of the custom date/time field.

  1. Navigate to Setup > Workflow Rules > + Create Rule.
  2. Select Leads from the module dropdown list.
  3. Provide a name for the rule. For example: "Notify Salespeople of New Leads".
  4. Add a description (optional), then click Next.
  5. In the Execute this workflow rule based on section, do the following:
    1. Choose the Date/Time field, then select Lead Assignment Time from the dropdown.
    2. Click Next.
  6. In the Which leads would you like to apply the rule to? section, specify the following conditions:
    • <Lead Status> <isn't> <Junk Lead | Lost Lead | Not Qualified>
    • <Lead Owner> <is not empty>
  7. Click Next.
  8. Under Instant Actions, select Email Notification.
  9. Provide a name for the notification, select the recipients, email template, and the from address.
  10. Click Save and Associate.
  11. Click Save on the workflow rule page.

Tip

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

Test the solution

  1. Navigate to Leads > +Create Lead.
  2. On the Lead Details page, enter the required information, including the owner, and then click Save.
    The first workflow rule will be triggered.
  3. Check whether the custom date/time field was updated with either 4:00 PM the same day or 11:00 AM the next business day, based on the time you created the lead.
    The second workflow rule will be triggered.
  4. Verify whether the email notification was sent to the lead's owner at the exact time specified in the custom field.

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

  • ModuleLeads
  • Trigger PointWorkflow Rule
  • EditionEnterprise and above
  • ComplexityHigh
  • Implementation Time60 minutes

Features used in the solution

Custom FieldWorkflow RuleDeluge 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!