
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;
toLong is a method that requires parentheses - toLong()equals with a wildcard pattern is contradictory
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;
toLong() is correctly called with parenthesesstarts_with is the right operator when using a wildcard patternConsider 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.