Assign leads based on users' shift timing.

 

Did you know?

Research shows that

  • Vendors who respond first to a prospect win 35-50% of the deals.
  • The chances of converting is 9x more if you reach a prospect within the first 5 minutes.

Business scenario:

The stats above prove an important point - the quicker your lead assignment, the better the chances of winning the deal. While auto-assigning on round-robin basis helps balance the load, it does not help meet the need of having to quickly reach out to your prospects operating across geographies. Assigning leads based on the time at which they are created, solves this problem. This is done by matching the lead acquisition time with sales reps' shift timing. This week's custom function helps do just that.

Getting started with the function:

  1. Go to Setup > Automations > Actions > Functions > Configure Function > Write your own.
  2. Provide a name for the function. For example: "Lead Assignment - Shift Timings".
  3. Select the moduleto be associated as Leads. Add a description(optional).
  4. Copy the code given below.
  5. Click "Edit arguments".
  6. Enter the name as "leadId" and select the value as "Lead Id".
  7. Click Save & Execute Script.
  8. Save the changes.

 

The Code:

For v2 Editor - DRE :

leadDetails = zoho.crm.getRecordById("Leads", input.leadId);
//info leadDetails;
createdtime = ifnull(leadDetails.get("Created_Time"),"");
createdhour=createdtime.toString("dd-MM-yyyy HH:mm:ss").toTime().getHour();
info createdhour;
if ((createdhour >= yy ) && (createdhour < zz ))
{
mp=map();
mp.put("Owner",xxxxxxxxxxxxxx);
update=zoho.crm.update("Leads", leadId.toLong(), mp);
info mp;
info update;
}

For v1 Editor:

leadIdStr = input.leadId.toString();
leadDetails = zoho.crm._getRecordById("Leads", input.leadId);
info leadDetails;
createdtime = ifnull(leadDetails.get("Created Time"),"");
createdhour=createdtime.toString("dd-MM-yyyy HH:mm:ss").toTime().getHour();
info createdhour;
if ((createdhour >= yy ) && (createdhour < zz ))
{
mp=map();
mp.put("SMOWNERID","xxxxxxxxxxxxxx");
update=zoho.crm._updateRecord("Leads", leadIdStr, mp);
info mp;
info update;
}

Note:

  • The code is zoho.crm._getRecordById for Version 1.0 of APIs.
  • Change the 'xxxxxxxxxxxxxx', to the User ID of the specific user.
  • The 'yy' and 'zz' refer to the time at which a lead is created. Use 24 hour time to set up a custom time window.
  • Assigning to a user requires the User ID and not the user name. The user ID is found in the Setup page of your CRM. Take a look at the screenshot below for more details.

 

Found this useful? Try it out and let us know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful!

Return to Tips