Deluge Count Total Records
Hi All,
Just wanted to share some code I created this morning that counts the total # of records in any module using Zoho Connections and API V2. All you have to do is create a connection to your CRM by clicking on the settings tab then click on "Connections" under Developer Space. Create your Zoho OAuth connection and copy your InvokeUrl code.
Hopefully Zoho can implement something better but for now this works for me and you can expand on it.
- max = collection("1","2","3","4","5","6");
- page = 0;
- Count = 0;
- for each record in max
- {
- page += 1;
- URL = "https://www.zohoapis.com/crm/v2/Leads?page="+page+"&per_page=200";
- response=invokeUrl
- [
- url: URL
- type: GET
- connection: zcrm
- ];
- Information = response.get("info");
- // This is the "info" section in the json list so that you can get the page info.
- Count += Information.get("count");
- // This gets the total number of records per page.
- MoreRecords = Information.get("more_records");
- // This is a boolean value. If there are more records it will be true.
- PageNumber = Information.get("page");
- // This gets the page number. I'm thinking of modifying the collection with this number to adjust the # of API calls if possible.
- if(MoreRecords == false)
- {
- info "Total Records: " + Count;
- return "No More Records";
- }
- }
- return "Finished";