Round-Robin Assignment in Zoho CRM using Custom Script

Round-robin Assignment of Records

Prerequisite: You must create a permanent record in the specific module, leads in this case and assign that record to the first user in round-robin. 

Here’s how you add this custom function to your CRM account:

  • Go to Setup>Automations>Actions >Custom Functions > Configure Custom Function > Write your own.
  • Enter the name of the Custom function. For example: “Round-robin assignment”.
  • Select the module as Quotes. Add a description(optional).
  • Click “Free flow scripting”.
  • Copy the code given below.
  • Click “Edit arguments”.
  • Enter the name as “leadId” and select the value as “Lead Id”.
  • Click Save.

As you have created a permanent record, this function does the assignment on a round-robin basis without errors. Note that the function won’t work if you don’t create a permanent record .

The code (based on Leads Module):


leadIdStr = input.leadId.toString();
firstRefRecordDetails = zoho.crm.getRecordById("Leads", xxxxxxxxxxxxx);
firstOwner = ifnull(firstRefRecordDetails.get("SMOWNERID"),"");
if (firstOwner = "User_ID_1")
{
UpOwner = "User_ID_2";
}
if (firstOwner = "User_ID_2")
{
UpOwner = "User_ID_1";
}
updatefirstRef = zoho.crm.updateRecord("Leads", "xxxxxxxxxxx", { "SMOWNERID" : UpOwner });
mp = map();
mp.put("SMOWNERID", UpOwner);
updateResp = zoho.crm.updateRecord("Leads", leadIdStr, mp);
info mp;
info updateResp;

Note:
  • Replace 'xxxxxxxxxx' with the permanent record id mentioned in the pre-requisite.
  • The above code is an example for assigning the records in the Leads module. You can use this code for any other module by changing the module name and parameters. 
  • 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.


    • Related Articles

    • Updating a Zoho CRM Subform (Accounts) from another Module (Deals)

      Updating a Zoho CRM Subform This script (courtesy of Zoho) will update existing records in a subform in one module (Accounts) from another Module (Deals). To create a cross-moduel subform entry (at creation for example), please see here ... ...
    • Sticky Notes in Zoho CRM

      Sticky notes in Zoho CRM are a great way to quickly jot down details about a call, a task or any other information that needs to be easily accessible. These are personal notes and not visible to other users in your CRM account. Sticky notes are ...
    • Event & Contact Sync between Office365 & Zoho CRM

      Connect your Meetings & Contacts between Zoho CRM and Microsoft Office 365.  in Office a new calender's is created called Zoho CRM, which you'll need to overlay in your Outlook. Events DO NOT sync to your personal calendar. The same applies to ...
    • Re-assigning your email address to the correct Zoho CRM instance

      Option 1: Deletes all Zoho services connected to your email address   1. Log into accounts.zoho.com (or accounts.zoho.eu depending on which server you're using) with your email address. 2. Click Preferences and select Close Account. This closes your ...
    • IPT Connect with Zoho CRM (IP Telecom) - Admin and User

      IPT Connect with Zoho When you integrate your hosted PBX with your Zoho CRM, you can use the IPT Connect app to avail of the benefits of Zoho Phonebridge. With Zoho Phonebridge, you can manage incoming and outgoing calls. It also reminds you about ...