Looking up relevant business information is easier when you have an internal search feature that targets certain keywords or phrases. Often times, this information will be worked with and manipulated to be useful for the current task the searcher is doing, which means that a faster internal search process will lead to better productivity.
The SearchRecord API is used to retrieve records that match your search criteria. It performs a module-level search based on either a phone number, email address, word, or other piece of criteria. It's most helpful to search for text in the fields of data type "string", "phone", or "Email".
In this post, we will look at an example that involves searching for and updating records using the searchRecord and updateRecord APIs. We'll first give the syntax followed by an example scenario.
ZOHO.CRM.API.searchRecord(config, page, per_page)
Here, config refers to the configuration object of the 'object' type, page refers to the page number, and per_page refers to the number of records to be generated per page.
SysRefName (of the module)
Allowed values "email|phone|word|criteria"
Note : Please check here for more details and limitations on SearchRecord API.
Here, config refers to the configuration object of the 'object' type.
SysRefName (of the module)
The trigger input can be "workflow", "approval", or "blueprint". If the trigger is not mentioned, the workflows, approvals, and blueprints related to the API will get executed. Enter the trigger value as  to not execute the workflows.
The data to be updated is constructed as
updateRecord's API Data parameter.
Let's take a simple scenario where a Zoho CRM user is handling a customer case. They would like to check if a similar problem has already been addressed in another case and if they can use any of those solutions for their own case. In our example, we will see:
- How the SearchRecord API can help the user find solutions using keywords related to the current case
- How the Search API returns the description and the solution of cases based on the keywords we enter
- How the user can update the correct solution to the current case if the relevant solution is found
SearchAPI.js code snippet
//Subscribe to the EmbeddedApp onPageLoad event before initializing the widget
//Search for solutions using input search words
//Searches across the cases module for the input text entered
//Looping through the solutions
for (i = 0; i < rec.length; i++)
/*populating the solution list list with the solutions and description of all the cases associated with the input text provided*/
/* Add the description-solution to the list only if the description or solution field is not null for the cases searched based on the input text */
if(solutionname!=null && solutiondescription!=null)
var solutionlist = document.getElementById("solutionlist");
var option = document.createElement("OPTION");
option.innerHTML = solutionsname;
option.value = solutionsid;
//Updates the solution to the solution field of the current case and changes the case status to closed
// Closes the widget popup
In the above code snippet, the input text keyed in is retrieved and passed as the Query parameter to the searchRecord API. The type parameter is passed as 'word', and the Entity parameter as 'Cases'. This searches across the Cases module for the input text and returns all the cases with the word present.
From the retrieved cases, the descriptions and solutions are fetched and populated into a select list. The user can have a look at the solutions and choose one if it resolves the current case issue.
The chosen solution is populated in the 'Enter solution here' textbox. The user can choose to edit the solution further according to their needs in the textbox and then click the 'Update Solution and close Case' button.
The updateRecord API will then update the solution entered to the solution field of the current case, and will change the status of the case to "Closed".
The user handles a case about a hardware issue. In the widget, they enter the word 'hardware' in the input field because it is a relevant word associated with the current case.
When the user clicks the 'Check for solutions' button, the searchRecord API returns all the descriptions and solutions involving 'hardware'. The user chooses a solution if it is relevant and makes further edits relevant to their case in the solution textbox. The 'Update Solution and close Case' button will update the solution to the solution field of the current case and close the ticket.
This was just an example, but there are many similar ways you can use the SearchRecord API to suit your specific business needs.
We hope you found this information useful. Keep following this space for more info!