Remove special characters and spaces

Format lead phone numbers in your CRM by removing special characters like parentheses, dashes, plus signs, and spaces.

When you generate leads through a form on your website or import them from external sources, it's possible to add phone numbers in various formats. For example, they may include special characters like parentheses, dashes, plus signs, or spaces. This could result in duplicate records (e.g., (123) 456-7890 vs. 1234567890), inefficient search results, and compatibility issues with third-party services such as SMS platforms and dialers that need a standardized numeric format. What if there were a quick workaround that formats leads' phone numbers with no special characters without any manual intervention? Our low-code tools can be a huge help in this situation.

Using functions, you can automatically remove special characters such as parentheses, dashes, plus signs, and spaces whenever a lead is created or modified in your CRM account. All you need to define is the characters you want to eliminate. Read on to learn more.

Permissions and availability

  • 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

  • Create a workflow rule for the Leads module that triggers every time a lead is created or modified in your CRM. Learn more
  • Write a custom Deluge function that formats lead phone numbers by removing special characters like parentheses, dashes, plus signs, and spaces. Learn more
  • Test the workflow rule in a sandbox before deploying it in your production environment. Learn more

Create a workflow rule

Follow the steps below to create a workflow rule in your Zoho CRM account:

  1. Navigate to Setup > Workflow Rules > +Create Rule.
  2. Select the Module as Leads from the dropdown list.
  3. Provide a name for the rule. For example: "Standardize phone number format".
  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.
    3. Click Next.
  6. In the Which leads would you like to apply the rule to? section, specify the condition as "<Phone> <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. On 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 leadId, and click Save.
    4. Click Save & Execute script.
  10. Click Save on the workflow rule page.
Create Workflow Rule

The code

Code Copied
a = zoho.crm.getRecordById("Leads",leadId);
ab = a.get("Phone").remove("-").remove(" ").remove("(").remove("+").remove(")");
info ab;
mp = map();
mp.put("Phone",ab);
up = zoho.crm.updateRecord("Leads",leadId,mp);
info up;

Notes

  • Make sure to use the accurate API names for their corresponding fields (e.g., "Phone") in the code snippet. Learn more.
  • The above script is an example of standardizing lead phone numbers by removing special characters like parentheses, dashes, plus signs, and spaces whenever a lead is created or edited in your CRM. You can use this code for any other module, such as contacts, or any field, such as mobile, by modifying the module name and parameters.

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 lead information and phone number with parentheses, dashes, plus signs, and spaces, then click Save. For example, +1(123) 456-7890.
    The workflow rule will be triggered.
  3. Check whether the lead's phone number field gets updated by removing parentheses, dashes, plus signs, and spaces.
  4. Try entering the phone number with parentheses, dashes, plus signs, and spaces in an existing lead record to check whether they get removed after saving the changes.

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
  • ComplexityLow
  • Implementation Time15 minutes

Features used in the solution

Workflow 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!