Searching Lead Records Using Client Script in Zoho CRM
Introduction: This article provides a step-by-step guide on how to search for existing Leads records in Zoho CRM using a client script. The example uses the Phone field to search for leads, but you can modify the criteria to search based on other fields as needed.
Client Script Code:
console.clear();
// Get the value from the Phone field
phone = ZDK.Page.getField("Phone").getValue();
console.log(phone);
// Search for leads with the specified phone number
search = ZDK.Apps.CRM.Leads.searchByCriteria("Phone:equals:" + phone);
console.log(search);
// Check if any leads were found
if (search.length > 0)
{
ZDK.Client.showMessage("Lead already present", {"type": "error"});
}
Instructions:
Field Selection: In this example, the script retrieves the value from the Phone field. You can modify this to search based on any other field by changing "Phone"
to the desired field name in the getField
method.
Criteria Format: The search criteria is formatted as "Field_Name:equals:Field_Value"
. Change Field_Name
to the desired field's name and Field_Value
to the value you want to search for.
Response Handling: If a lead matching the search criteria is found, an error message "Lead already present" will be displayed.