Print

ZohoCRM: zoho.crm.searchRecords only returns certain records

What?
This is an article to hopefully resolve for you quicker than it took me, why a zoho.crm.searchRecords() returns some of the records but omits others.

Why?
The use-case was that we were creating a custom related list on a Zoho Finance > Sales Orders module but it wasn't finding all the Quotes related to this Sales Order.

How?
The quick answer is buried in Zoho documentation and due to the searchRecords function requiring it's 5th parameter which defaults to "not converted" records:
copyraw
<variable>=zoho.crm.searchRecords(<module_name>,<criteria>,<page>,<per_page>,<search_value>,<connection>);
  1.  <variable>=zoho.crm.searchRecords(<module_name>,<criteria>,<page>,<per_page>,<search_value>,<connection>)

The solution:
The long answer/investigation is
  1. getting a JSON response with a zoho.crm.getRecordByID() with a quote that works and a quote that doesn't
  2. Comparing both records JSON and finding the $converted system field is different.
  3. Checking the Zoho documentation for an example showing how you can get all results irrespective of whether they are converted or approved:
    copyraw
    response = zoho.crm.searchRecords("Quotes", "(Ref:equals:QU-00001)",1,200,{"converted":"both","approved":"both"});
    1.  response = zoho.crm.searchRecords("Quotes", "(Ref:equals:QU-00001)",1,200,{"converted":"both","approved":"both"})
  4. Done. Ta daa!

Source(s):
Category: Zoho :: Article: 755