Combine first and last names

Automatically combine a lead's first and last names and save the formatted full name in a custom field in Zoho CRM.

Sales teams often require a single Full Name field in lead records that combines the First Name and Last Name fields. This combined field is useful for mail merge templates, reports, and downstream integrations. For example, if the First Name is "John" and the Last Name is "Doe", the Full Name field would display as "John Doe."

If you take a cursory look at the Leads module in your CRM, you'll notice that a Full Name field is not available as a standard editable field. While you could use a formula field, it doesn't store the full name in a regular text field. Unfortunately, there's no built-in method to populate a combined name into a custom field directly. This is where our low-code tools come in handy.

A workflow rule powered by a custom function can combine a lead's first and last name and update the full name in a custom field on the same lead record. This ensures that the full name is readily available for automations, integrations, exports, and personalized communication templates. 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 single-line field to the Leads module. This field will hold leads' combined first and last names. 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 that updates the lead's full name in the custom field, and link it to the workflow rule. Learn more
  • Test the workflow rule in a sandbox before deploying it in your production environment. Learn more

Add a custom field

The first step is to add the custom single-line 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 single-line field from the New Fields tray to the desired section of the layout.
  4. Name the single-line field (e.g., "Lead Name"), define its properties as required, and click Done.
    Note: You cannot name the field “Full Name” because it's already in use for backend operations.
  5. Once you've finished, click Save and Close.

Create a workflow rule

Next, create a workflow rule and connect it with a custom function.

  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: "Combine first and last names".
  4. Add a description, if required, then click Next.
  5. In the Execute this workflow rule based on section, do the following:
    1. Choose Record Action, then select Create or Edit from the dropdown.
    2. Check the box for Repeat this workflow whenever a lead is edited option.
    3. Click Next.
  6. In the Which leads would you like to apply the rule to? section, specify the condition as "<Lead Name> <is not empty>", 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 provided below.
    2. Click Edit Arguments.
    3. Enter the name as leadId, select the value as Leads - Lead Id, and click Save.
    4. Click Save & Execute Script.
  10. Click Save on the workflow rule page.

The code

Code Copied
leadDetails = zoho.crm.v8.getRecordById("Leads", input.leadId);
first = ifnull(leadDetails.get("First_Name"),"");
last = ifnull(leadDetails.get("Last_Name"),"");
if ( first != "")
{
name = first + " " + last ;
}
else
{
name = last ;
}
mp=map();
mp.put("Lead_Name",name);
update = zoho.crm.v8.updateRecord("Leads",leadId.toLong(),mp);
info mp;
info update;

Notes

  • Use the accurate API name of the custom single-line field in the code snippet (e.g., "Lead Name"). Learn more
  • The code above is an example of concatenating a lead's first and last name and saving the full name in a custom field on the lead. You can adapt this code for any other module (such as Deals) or to combine values of any other fields by modifying the module name and field parameters as needed.

Tip

  • Configure and test the solution 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 details, including First Name and Last Name, and click Save.
    The workflow rule will be triggered.
  3. Check whether the Lead Name field is populated with the concatenated full name (e.g., "John Doe").
  4. Test edge cases by creating a lead with only a Last Name; the custom field should contain just the last name.

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

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!