How to search ZOHO CRM Contacts using Phone value?

How to search ZOHO CRM Contacts using Phone value?


Warning

The Error

When attempting to search for contacts by phone number in Zoho CRM, you might encounter errors with this script:

con = phn.toLong; 
contactdetails = zoho.crm.searchRecords("Contacts",("Phone:equals":con*")); 
info contactdetails;

Common Issues in This Script

  1. Missing ParenthesestoLong is a method that requires parentheses - toLong()
  2. Incorrect Query Format: The search criteria uses an invalid syntax with misplaced parentheses and quotes
  3. Improper Search Operator: Using equals with a wildcard pattern is contradictory


Idea

Optimized Solution

The correct script to search for contacts by phone number is:

con = phn.toLong(); 
contactdetails = zoho.crm.searchRecords("Contacts", "Phone:starts_with:" + con + "*"); 
info contactdetails;

Why This Works Better

  1. Proper Method CalltoLong() is correctly called with parentheses
  2. Correct Search Criteria Format: The search criteria is formatted as a string with proper concatenation
  3. Appropriate Operatorstarts_with is the right operator when using a wildcard pattern

Additional Optimization Tips

  • Consider adding error handling to manage cases where phn cannot be converted to a number:

    try {
        con = phn.toLong();
        contactdetails = zoho.crm.searchRecords("Contacts", "Phone:starts_with:" + con + "*");
        info contactdetails;
    }
    catch(e) {
        info "Invalid phone number format: " + e;
    }
    
  • For international phone numbers, consider removing common prefixes (like "+") before conversion:

    cleanPhone = phn.replaceAll("[^0-9]", "");
    con = cleanPhone.toLong();
    
  • For better performance with large datasets, be as specific as possible with your search criteria to reduce the result set size

This optimized approach ensures reliable contact searches while avoiding common syntax errors in your Deluge scripts.

    • Related Articles

    • What is Zoho CRM Phone Integration?

      Zoho CRM Phone Integration enables users to integrate their phone system with Zoho CRM. This feature allows calls to be made directly from the CRM and automatically logs them, enhancing communication efficiency and tracking. This integration enhances ...
    • how to create a Zoho Desk ticket with custom lookup field value?

      Regarding your concern, we understand that you are trying to create ticket in desk from Zoho Creator. if that's the case, we request you to follow the below format as mentioned in add records api help doc "Lookup_field_name": "3888833000000114027". ...
    • How to define number of subform rows dynamically using script in Zoho Creator?

      It´s important to highlight that this post assumes you are already familiar with proper subform creation in Zoho Creator. If you are not please check out our Master Zoho Creator Subforms course in the url below before implementing this custom ...
    • How can Zoho CRM benefit photographers?

      Zoho CRM can benefit photographers in several ways by streamlining their business operations, enhancing client relationships, and boosting sales. Here are some key benefits: Benefits for Photographers Contact and Lead Management: Zoho CRM allows ...
    • How to properly set Subforms in Zoho Creator Part 3

      The first step is to have the Subtotal or Total field value in the Order Form. Normally this would be a currency field or decimal field if you need to consider 1 or more decimals into your calculations. If not you can also set it the field as a ...