Many businesses conduct conferences and workshops to generate new leads and update existing customers about the latest developments. These events often use an event registration form with a multi-select field that lets attendees choose from a list of sessions they wish to attend, such as keynote speeches, workshops, and networking events. Similarly, if events occur in different locations, attendees can select various sessions at each location using multiple multi-select fields.
Based on the number of sessions selected, the business can engage attendees with early bird promotions, discounted entry fees, and various other incentives. However, the current version of CRM lacks a direct way to track and update the total number of sessions attendees select across the multi-select fields. This is when our low-code tools can come in handy.
Suppose your business follows this or a similar practice where you want to know the number of selections in multi-select fields. You can create a custom function to count and update the number in a custom field of the record. Read on to learn more.
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 number field named "Total Sessions" in the Leads module. This is where the function will update the total number of sessions chosen in the multi-select fields. Learn more
- Create a workflow rule for the Leads module that triggers every time a lead is created or edited. Learn more
- Write a custom Deluge function and link it up with the workflow rule. 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 is adding a custom number field to the Leads module.
- Navigate to Setup > Customization > Modules and Fields.
- Click the Leads module to open the layout editor.
- Drag and drop the Number field from the New Fields tray to the desired section of the layout.
- Name the number field (e.g. "Total Sessions") and define its properties as required.
- Once you have finished, select Done, then click Save and Close.
Create a workflow rule
Next, create a workflow rule that updates the total count of selected sessions.
- Navigate to Setup > Workflow Rules > +Create Rule.
- Select Leads from the module dropdown list.
- Provide a name for the rule. For example: "Update Total Sessions".
- Add a description (optional) and then click Next.
- In the Execute this workflow rule based on section, do the following:
- Choose Record Action, then select Create or Edit from the dropdown.
- Check the Repeat this workflow whenever a lead is edited option.
- Click Next.
- In the Which leads would you like to apply the rule to? section, select All Leads, then 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 given below.
- Click Edit Arguments.
- Choose Leads - Lead Id, name it leadId, and then click Save.
- Click Save & Execute script.
- Click Save on the workflow rule page.
The code
getrecord = zoho.crm.getRecordById("Leads",leadId);
field1 = ifnull(getrecord.get("Field_Name_1"),"");
field2 = ifnull(getrecord.get("Field_Name_2"),"");
field3 = ifnull(getrecord.get("Field_Name_3"),"");
if(field1 != "")
{
field1count = field1.size();
}
else
{
field1count = 0;
}
if(field2 != "")
{
field2count = field2.size();
}
else
{
field2count = 0;
}
if(field3 != "")
{
field3count = field3.size();
}
else
{
field3count = 0;
}
finalcount = field1count + field2count + field3count;
mp = Map();
mp.put("Total_Sessions",finalcount);
info zoho.crm.updateRecord("Leads",leadId,mp);
Notes
- Replace "Field_Name_1", "Field_Name_2", and "Field_Name_3" with the corresponding API names of the multi-select fields in your lead record.
- Make sure to use the accurate API names for their corresponding fields in the code snippet (e.g., "Total Sessions"). Learn more
- You can modify the code snippet to track a single multi-select field or extend it for multiple fields.
- The script above is an example of tracking the number of options selected in one or more multi-select fields and updating it in a custom number field within a lead record. You can customize this code to track selections in other modules by changing the module, field names, 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
- Navigate to Leads > +Create Lead.
- On the Lead Details page, select the required sessions in the three multi-select fields, then click Save.
The workflow rule will be triggered. - Check whether the Total Sessions field reflects the number of sessions chosen in the three multi-select fields.
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
- ComplexityMedium
- Implementation Time30 minutes

Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST