COQL or deluge API, how to get the total count that match criteria?
This is a simple count, but given the 200 record limit, and the fact that I don't need any of the results, just the count, why do I have to page through and perform such an expensive operation. The following shows how I successfully used deluge and COQL to aggregate a count, but again, there must be an easier way that is less expensive. The following I use to count Contacts, and it iterates 32 times, that's 32 queries, just to get a single number: row count.
- selectQuery = "select id from Contacts WHERE id is not null";
/**
* @param {String} selectQuery - The select query to be executed
* e.g. select id from module where id is not null
* NOTE: the select query will have limit appended to it. You must select the id.
*/
queryMap = Map();
attempt = " ";
retryLoop = attempt.leftPad(99).replaceAll(" ",","); // Creates 100 loops
iteration = 0;
aggregateIds = List();
for each retry in retryLoop
{
info "iteration: " + iteration;
queryMap.put("select_query", selectQuery + " limit " + iteration*200 + ", 200");
response = invokeurl
[
url :"https://www.zohoapis.com/crm/v3/coql"
type :POST
parameters:queryMap.toString()
connection: "coql"
];
// Create a combined List
for each pointer in response.get("data")
{
aggregateIds.add(pointer.get("id"));
}
if(response.get("info").get("more_records") == false)
{
break;
}
iteration = iteration + 1;
}
aggregateIdsSize = aggregateIds.size();
info "aggregateIds: " + aggregateIdsSize + " for " + selectQuery;
return aggregateIdsSize;
How can this be done more simply, with less computation and complication?
Zoho Desk Resources
-
Desk Community Learning Series
-
-
-
-
-
-
-
-
-
Zoho CRM Plus Resources
Zoho Books Resources
Zoho Subscriptions Resources
Zoho Projects Resources
Zoho Sprints Resources
Zoho Orchestly Resources
Zoho Creator Resources
Zoho WorkDrive Resources
Zoho Campaigns Resources
Zoho CRM Resources
Writer Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.