Custom Function: Searching Events in the current month - with record count

Custom Function: Searching Events in the current month - with record count

I hate to be a bother to the fine folks here, but I'm stuck in another function.  GOAL:  write a custom function to count the number of Meetings each person in Contacts has for the current month, then push that count to a field in the contact record.  

Spent about 6 hours trying different versions of the function, none work. Original code below. I think I might have to use CoQL query for the function, but was hoping to avoid it. Never used APIs.

Attempts so far:  Tried to iterate in various forms & found out Deluge doesn't support iterative loops with increments. Found out CRM deluge doesn't support count() for a collection, it's only applicable to Creator according to help docs. And the integration task "zoho.crm.searchrecords" only supports equals and starts with as criteria, so I can't search "in" the current month.

Then I thought about using intersect(). But now currently thinking,  in natural language: "for each name in Contacts, select query search Meetings this month where Event_Title contains name" and return count of record, I assume using size(). 

So, maybe I need to use a "for each" loop on Contacts with a CoQL select query for meetings in the current month where the Event_Title field contains the contact's name. 

Really frustrating as a non-dev. I'm sure there's multiple ways to do it but I can't figure it out due to search criteria limitations. Makes me feel stupid, and it feels like there's information missing from the help documents.

Original Code (trying to iterate, mistakes and all):
  1. Startdate = zoho.currentdate.toStartOfMonth();
  2. Enddate = Startdate.addMonth(1);
  3. eventlist = zoho.crm.searchRecords("Events","Start_DateTime : in : this month");
  4. myList = eventlist.toList();

  5. for each  rec in clients
  6.       {
  7. name = rec.getJSON("Last_Name");
  8. ident = rec.getJSON("id");
  9. sessioncount = 0;
  10. for each  meeting in myList
  11. {
  12. title = meeting.getJSON("Event_Title"); 
  13. if(title.contains(name) == true && title.contains("training") == true)  //this line would NOT work if "eventlist" was still a collection variable, so I had to convert it to List variable
  14. {
  15. sessioncount +=1;
  16. }
  17. }
  18. mp = Map();
  19. mp.put("Scheduled Sessions",sessioncount);
  20. info name;
  21. info sessioncount;
  22. info mp;
  23. //update = zoho.crm.updateRecord("Contacts",ident,mp);
  24. //info update;
  25. }

Obviously problems there. Now trying to use the CoQL api, but I've never done APIs before. 
Relevant code below. You can see several versions of the searchRecords task based on different community/help docs, but none seem to work.

Code below just tries to return ALL the Meetings in the current month to get proof of concept. Returns Invalid Query. Sessioncount should be 116, but returns 4... I have no idea where that's from.
  1. //eventlist = zoho.crm.searchRecords("Events","(Start_DateTime:equals:"+Startdate.toString("yyyy-MM-dd")+")");
  2. eventlist = zoho.crm.searchRecords("Events",{"select_query":"SELECT Event_Title FROM Events where Start_DateTime in'"+Startdate+"'"});

  3. //eventlist = zoho.crm.getRecords("Events",1,400,query_map);
  4. //myList = eventlist.toList();


  5. queryMap = Map();
  6. queryMap.put("select_query", "select Event_Title, Start_DateTime from Events where Start_DateTime in '"+Startdate+"'");
  7. response = invokeurl
  8. [
  9. url :"https://www.zohoapis.com/crm/v3/coql"
  10. type :POST
  11. parameters: queryMap.toString()
  12. connection:"crmconnection_all"
  13. ];
  14. info response;
  15. sessioncount = eventlist.size();
  16. info sessioncount;

Does anybody have an approach they could share?  I've pulled my hair out!

    Access your files securely from anywhere



                      Zoho Developer Community




                                              • Desk Community Learning Series


                                              • Digest


                                              • Functions


                                              • Meetups


                                              • Kbase


                                              • Resources


                                              • Glossary


                                              • Desk Marketplace


                                              • MVP Corner


                                              • Word of the Day


                                              • Ask the Experts



                                                        • Sticky Posts

                                                        • Zoho CRM Functions 53: Automatically name your Deals during lead conversion.

                                                          Welcome back everyone! Last week's function was about automatically updating the recent Event date in the Accounts module. This week, it's going to be about automatically giving a custom Deal name whenever a lead is converted. Business scenario Deals are the most important records in CRM. After successful prospecting, the sales cycle is followed by deal creation, follow-up, and its subsequent closure. Being a critical function of your sales cycle, it's good to follow certain best practices. One such
                                                        • User Tips: Auto-Create Opportunity/Deal upon Quote Save (PART 1)

                                                          Problem: We use quotes which convert to sales orders but Users / Sales Reps do not create opportunities / deals and go straight to creating a quote. This leads to poor reporting. Implementing this solution improves reporting and makes it easier for users.
                                                        • Custom Function : Automatically send the Quote to the related contact

                                                          Scenario: Automatically send the Quote to the related contact.  We create Quotes for customers regularly and when we want to send the quote to the customer, we have to send it manually. We can automate this, using Custom Functions. Based on a criteria, you can trigger a workflow rule and the custom function associated to the rule and automatically send the quote to customer through an email. Please note that the quote will be sent as an inline email content and not as a PDF attachment. Please follow
                                                        • Function #50: Schedule Calls to records

                                                          Welcome back everyone! Last week's function was about changing ownership of multiple records concurrently. This week, it's going to be about scheduling calls for records in various modules. Business scenario Calls are an integral part of most sales routines.. Sales, Management, Support, all the branches of the business structure would work in cohesion only through calls. You could say they are akin to engine oil, which is required by the engine to make all of it's components function perfectly. CRM
                                                        • Function #37: Create a Purchase Order from a Quote

                                                          Welcome back everyone! Last week, we learnt how to calculate the total number of activities for a lead and further take note of the activity count for particular dates. For instance, from the period of Demo to Negotiation. This week, let's look at a function that lets you create a Purchase Order instantly from a Quote. Business scenario: In any form of business, one of the most important things to do is to document the transactions. Naturally, negotiation, signing an agreement, placing an order,


                                                        Manage your brands on social media



                                                              Zoho TeamInbox Resources



                                                                  Zoho CRM Plus Resources

                                                                    Zoho Books Resources


                                                                      Zoho Subscriptions Resources

                                                                        Zoho Projects Resources


                                                                          Zoho Sprints Resources


                                                                            Qntrl Resources


                                                                              Zoho Creator Resources



                                                                                  Zoho CRM Resources

                                                                                  • CRM Community Learning Series

                                                                                    CRM Community Learning Series


                                                                                  • Kaizen

                                                                                    Kaizen

                                                                                  • Functions

                                                                                    Functions

                                                                                  • Meetups

                                                                                    Meetups

                                                                                  • Kbase

                                                                                    Kbase

                                                                                  • Resources

                                                                                    Resources

                                                                                  • Digest

                                                                                    Digest

                                                                                  • CRM Marketplace

                                                                                    CRM Marketplace

                                                                                  • MVP Corner

                                                                                    MVP Corner





                                                                                      Design. Discuss. Deliver.

                                                                                      Create visually engaging stories with Zoho Show.

                                                                                      Get Started Now


                                                                                        Zoho Show Resources


                                                                                          Zoho Writer Writer

                                                                                          Get Started. Write Away!

                                                                                          Writer is a powerful online word processor, designed for collaborative work.

                                                                                            Zoho CRM コンテンツ








                                                                                              Nederlandse Hulpbronnen


                                                                                                  ご検討中の方




                                                                                                        • Recent Topics

                                                                                                        • We Cannot send A/B campaign since the number of contacts chosen is less than 4.

                                                                                                          My recipient list has 290 contacts, but it fails to send at the last step with an error: "We Cannot send an A/B campaign since the number of contacts chosen is less than 4." How to solve this?
                                                                                                        • Facing issue in getting data through api calls

                                                                                                          I have send data of users and want to get the data oof users but facing issue with one field for that I want help
                                                                                                        • New App Menu Doubt and Question

                                                                                                          Hi member, Now my Creator C6 able to have the Newest App Menu. The UI is nice. But I have several questions about this feature. 1) I construct two Title on above a component. But only one Title will be shown. Is it a bug or intended behavior? In fact,
                                                                                                        • Wokrdrive Api assistance needed

                                                                                                          Hello fellow developers, I'm currently working on integrating Zoho WorkDrive with a Bubble.io application using the OAuth 2.0 User-Agent Flow. I've encountered a few issues during the setup and testing phase, and I'm hoping someone here might have some
                                                                                                        • Configure ChatGPT in Zoho Cliq | Now with GPT-4!

                                                                                                          Updated for GPT-4 Support: The post and scripts has been revised to take advantage of the new GPT-4 model's capabilities. Please use the updated version for enhanced performance and accuracy. If you have been on the internet for the past few months, you
                                                                                                        • Relay Mail Failed

                                                                                                          Hello, We are using SMTP Relay Settings in ZOHO CRM for sending emails using office 365 server. But every time we are receiving below errors. The Relay Configuration for the domain Domain.com and feature WorkFlow has failed 3 times today . Mails will
                                                                                                        • Zoho Books (UK) needs to be able to submit a CT600 CTSA return

                                                                                                          As well as a VAT Return, most (if not all) small businesses have to submit a CT600 Corporation Tax Self-Assessment. There are many providers who do this (like Xero) bujt not Zoho. Can you add this to the request list please? Many thanks Steve
                                                                                                        • How do I make a stock tracked item on my sales orders not automatically fulfill?

                                                                                                          I use the sales order process to track what jobs I still need to complete and send out, and which ones are complete. I have items that are not tracked in my inventory, but are NOT listed as service items, and are not being manually typed in to the sales
                                                                                                        • Call Transcription: Zia and RingCentral

                                                                                                          Can I use telephony integration with RingCentral for call transcription/recording? In my CRM Setup > Zia > Communication > Call Transcription, if I try to enable it, it gives a warning "Please set up a telephony integration and then enable call recording
                                                                                                        • Instant Sync of Zoho CRM Data?

                                                                                                          With how valuable Zoho Analytics is to actually creating data driven dashboards/reports, we are surprised that there is no instant or near instant sync between Zoho CRM and Zoho Analytics. Waiting 3 hours is okay for most of our reports, but there are
                                                                                                        • Sales Returns - Repairand Return

                                                                                                          Hi Inventory Team, I'm working with a client on an Inventory implementation project and they have shared this use case with me. Some items may be returned by the customer, then returned to the vendor for repairs, received from the vendor and shipped back
                                                                                                        • Display name in Zoho Desk Ticketing system

                                                                                                          We are in the trial phase to implement a Ticketing system. As our company uses several generic emails, such as service@abc.com and service@xyz.com across different branches, the uniqueness of usernames (full names) becomes crucial for our business. Without
                                                                                                        • Desk Contact Name > split to First and Last name

                                                                                                          I am new to Zoho and while setting up the Desk and Help Center, I saw that new tickets created or submitted from the Help Center used the Contact Name field. This would create a new Contact but put the person's name in the Last Name field only. The First
                                                                                                        • invokeURL to change custom field

                                                                                                          I have a deluge script that currently runs as a Schedule. It works exactly as intended, however I've recently been informed by Zoho that there's some mechanism in place to block changes made by a script when it runs on a schedule from being detected by
                                                                                                        • Customize the ticket ID for enhanced ticket tracking

                                                                                                          Hello everyone, Ticket IDs in Zoho Desk are the unique reference numbers that are assigned to tickets when they're created. Agents generally use the ticket ID to locate a particular ticket and to reference a ticket in conversations and feeds. When customers
                                                                                                        • Where do we manage tags?

                                                                                                          Where is the page where we can view all tags and manage them (like change a tag name to something else or merge tickets under a particular tag with another)?
                                                                                                        • Hosted Payment Pages - how to update the address in zoho billing

                                                                                                          I"m playing around with the muti-page hosted payment pages which have places for customers to enter their addresses when paying. Why does this not update their address in Zoho Billing after payment? What can I do to make this happen?
                                                                                                        • Conditional Layouts On Multi Select Field

                                                                                                          How we can use Conditional Layouts On Multi Select Field field? Please help.
                                                                                                        • Submitting candidates to clients when there is no Vacancy

                                                                                                          Hi I am working in a niche sector so when I register a candidate I want to immediately send their CV to relevant clients/contacts.  They will not have Vacancies on the system so what's the quickest way of sending/submitting their CV quickly to a list of clients in a particular area without just using an email and attachment? Should be easy to just send out "speculatively" CV's to qualified clients but I cant find a quick way to do this !
                                                                                                        • Surely it's time Inline editing from views

                                                                                                          I think the first request I found for in-line editing from grids was approximately 12 years ago - that post was locked because it was suggested Zoho sheetview solved the problem. However, it's now 2024, and in-line editing from grids is just a basic expectation.
                                                                                                        • Highlight a candidate who is "off limits"

                                                                                                          Hello: Is there a way to highlight a candidate who is "off limits"?  I would like to have the ability to make certain candidate and / or Client records highlighted in RED or something like that.   This would be used for example when we may have placed a candidate somewhere and we want everyone in our company to quickly and easily see that they are off limits.  The same would apply when we want to put a client or former client off limits so no one recruits out of there. How can this be done? Cheers,
                                                                                                        • Set a global default filter to All Candidates view

                                                                                                          Hi, Is it possible to set a global filter to the All Candidates view? As a use case would be for off-limit candidates. These are those who are off limits due to previous bad client feedback on performance/behaviour. Ideal use case would be to set these
                                                                                                        • Dialing Microsoft Teams Phone Service via Zoho CRM

                                                                                                          I am using the VOIP option in Microsoft teams for my office phone system. I was hoping to have a way to dial numbers directly from Zoho CRM, but don't see anything in the Teams Integration or in the Telephony integration that will enable this. Does anyone
                                                                                                        • Getting error "invalid warehouse_id" when trying to update any transaction in Zoho books

                                                                                                          I got a message from Zoho saying that the Warehouse and Branch has been merged into one category "Locations" Once I migrated to this setup I was no longer able to edit any invoice / create creadit notes - got an error saying "invalid warehouse_id" I never
                                                                                                        • Sendmail to Hotmail not delivered, or in spams

                                                                                                          Hello, I know that Hotmail / OUtlook have been a problem with sending mail, but I think there is a way to parameter Creator to lessen the problems with that. Anyone can tell me how ? Sylvain
                                                                                                        • Multiple packages in one shipment

                                                                                                          Guys we have been asking for this for years. we want to be able to ship multiple packages for one customer in the same shipment, so as to avoid entering shipping info repeatedly, and avoid customer getting multiple tracking emails. When does this arise?
                                                                                                        • Received fatal alert: handshake_failure

                                                                                                          We have for most than 2 weeks these error, it is the third time these year webhooks arent working how they are supposed to. If we use an external sender ( POSTMAN) the webhooks work smootlhy Does anybody have the same error?
                                                                                                        • Max iteration for Experience Details

                                                                                                          Hi, it's currently impossible to add more than 10 experience details iterations, a pop-up error message is displayed. Could you please remove this rule ? We currently have several Senior Freelance Consultant with more than 20 even 30 experience details.
                                                                                                        • Route Optimizer

                                                                                                          Does Zoho Inventory offer route optimization for our in-house deliveries? It will save us time to manually route our daily orders. Thank you
                                                                                                        • How would you handle Warranty replacement parts or items in zoho inventory

                                                                                                          Hi everyone, I'm working on setting up zoho inventory for our distribution business.  We handle the service for our customers and will replace items that malfunction under a warranty basis.  Does anyone else do this and how do you set it up in inventory?  Do you have to create a sales order and if you want to the original item back, do you use a RMA?  If so, how is it done so there isn't a credit memo associated with it? Thanks, Tim
                                                                                                        • Inner height of calendar inside a page

                                                                                                          I have a page in Creator with 4 calendars inside it. I reduce their height to all make them fit inside tha screen without scrolling(see image blue contour). I would like to remove the scroll INSIDE each calendar. Is there a way to modify the height of
                                                                                                        • Introducing Linkthread by Zoho Social — our new link in bio tool

                                                                                                          Hey everyone, We hope you're all doing amazing. We always love bringing features and tools to make your social media marketing journey easier, and today, we've got a brand new tool that we'd like to introduce to you. We know how important it is to make
                                                                                                        • Beyond months: Zoho CRM now supports custom fiscal year formats

                                                                                                          Hello (again) folks ! You can now set your CRM's fiscal year to follow the 4-5-4 calendar and other widely used 52-week fiscal year formats. Why this change? As you know, the fiscal year of an organization may not coincide with the Gregorian calendar
                                                                                                        • Proper syntax for filtering Added_Time in the URL using functionality-based URLs

                                                                                                          I haver intermediate knowledge of functionality-based URLs. I say that because when I use them, it is never straight forward with me. Sometimes it works first try, and sometimes I spend hours exploring to find the proper syntax. link to operators: https://help.zoho.com/portal/en/kb/creator/developer-guide/others/url-patterns/articles/functionality-based-urls#List_of_operators_and_their_constants
                                                                                                        • update Deals Stage/Pipeline if zoho forms filled out

                                                                                                          Hello, I'm having a problem at the moment and would like to ask for your help. in the lead status “pre-qualification” i send an email through the blueprint with a zoho-forms form that the recipient has to fill out. it is then also converted to contact+deal.
                                                                                                        • old invoices (Exchange rate)

                                                                                                          We have been facing an issue and searching for a solution for over a month. Issue: Previously, the exchange rate in Zoho Books and Zoho CRM was incorrect, and invoices were being recorded in Zoho CRM with the wrong exchange rate. After adjusting the exchange
                                                                                                        • Announcing Early Access to "Zoho CRM for Everyone" — A new and exciting update to Zoho CRM

                                                                                                          We are delighted to announce an Early Access to Zoho CRM for Everyone— a truly democratic approach to managing a CRM, gift-wrapped in an exciting and intuitive user interface. Here, multiple teams across an organization can coordinate among each other
                                                                                                        • New Line in Double Optin Email

                                                                                                          Hello, is it possible to add new lines to the double optin email? This is necessary to add legal informations to the mail, which would look very messy if it is all in one line. Thank you in advance Carsten
                                                                                                        • Is there a way to request a password?

                                                                                                          We add customers info into the vaults and I wanted to see if we could do some sort of "file request" like how dropbox offers with files. It would be awesome if a customer could go to a link and input a "title, username, password, url" all securely and it then shows up in our team vault or something. Not sure if that is safe, but it's the best I can think of to be semi scalable and obviously better than sending emails. I am open to another idea, just thought this would be a great feature.  Thanks,
                                                                                                        • Can it change the language ?

                                                                                                          Hello ! The question is in the title ;)
                                                                                                        • Next Page