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?
Access your files securely from anywhere
Zoho Developer Community
Deliver unforgettable customer experiences
Deliver unforgettable customer experiences
New to Zoho Marketing Plus?
Everything you need to run your marketing
New to Zoho Marketing Plus?
Everything you need to run your marketing
Zoho Desk Resources
-
Desk Community Learning Series
-
-
-
-
-
-
-
-
-
Sticky Posts
Client Script | Update - Introducing Commands in Client Script!
Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands
Extension Pointers - JS SDK series #4: Managing data from a widget using ZOHO.CRM.HTTP
Handling and managing the data between two applications is a major factor for an efficient business. There are a variety of ways to handle data between Zoho CRM and other third-party applications. You can use deluge CRM tasks, create connectors, use API
Kaizen #152 - Client Script Support for the new Canvas Record Forms
Hello everyone! Have you ever wanted to trigger actions on click of a canvas button, icon, or text mandatory forms in Create/Edit and Clone Pages? Have you ever wanted to control how elements behave on the new Canvas Record Forms? This can be achieved
Extension pointers for integrating Zoho CRM with Zoho products #8: Upload and manage Zoho Workdrive folders and files from within Zoho CRM
Keeping records on your customers and business prospects is essential for tracking data, conducting follow-ups, and running a business smoothly. When you use two separate applications, and store relevant data in each, checking and tracking data becomes
Kaizen #142: How to Navigate to Another Page in Zoho CRM using Client Script
Hello everyone! Welcome back to another exciting Kaizen post. In this post, let us see how you can you navigate to different Pages using Client Script. In this Kaizen post, Need to Navigate to different Pages Client Script ZDKs related to navigation A.
Zoho TeamInbox Resources
Zoho DataPrep Resources
Zoho CRM Plus Resources
Zoho Books Resources
Zoho Subscriptions Resources
Zoho Projects Resources
Zoho Sprints Resources
Qntrl Resources
Zoho Creator Resources
Zoho Campaigns Resources
Zoho CRM Resources
Zoho Show Resources
Writer Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.