Check Contacts for scheduled calls

Check Contacts for scheduled calls

HI guys!

I really hope sonmeone can help, I am battling with the logic of my code. Here is the use case scenarion, we heavily use the call smodule in ZOHO, i have a workflow that triggers and schedules calls dependinf on the outcome of a call.
We have some contacts ( and by extension, Accounts) that dont have scheduled calls against them. We have few thousand Contacts loaded already. I need the code to check which accounts dont have any scheduled calls or any calls at all. I can get the checking for calls at all part right, but where I am battling is that if a contact has a completed call, but not a SCHEDULED call, the code is still picking it up as having a scheduled call, even though the call on that contact is in the past and has been completed. Below is the code, please can you help me understand where its going wrong.
  1. loop = {1,2,3};
  2. alist = List();
  3. for each  ele in loop
  4. {
  5. resp = zoho.crm.getRecords("Accounts",ele,200);
  6. if(resp.size() == 0)
  7. {
  8. break;
  9. }
  10. for each  rec in resp
  11. {
  12. Val = "";
  13. relcont = zoho.crm.getRelatedRecords("Contacts","Accounts",rec.get("id"));
  14. if(relcont.size() != 0)
  15. {
  16. for each  ele in relcont
  17. {
  18. relcalls = zoho.crm.getRelatedRecords("Calls","Contacts",ele.get("id"));
  19. if(relcalls.size() = 0)
  20. {
  21. alist.add(rec.get("id"));
  22. }
  23. else if(relcalls.size() != 0)
  24. {
  25. for each  call in relcalls
  26. {
  27. ctime = call.get("Call_Start_Time").toTime("yyyy-MM-dd'T'HH:mm:ss");
  28. if ((ctime > now) && (relcalls.size() > 0))
  29. {
  30. Val = "Yes";
  31. }
  32. }
  33. }
  34. }
  35. }
  36. }
  37. if(Val == "")
  38. {
  39. alist.add(rec.get("id"));
  40. }
  41. }
  42. info "Account Count : " + alist.size();
  43. info "Account List : " + alist;

      Zoho Developer Community








                                Zoho Desk Resources

                                • Desk Community Learning Series


                                • Digest


                                • Functions


                                • Meetups


                                • Kbase


                                • Resources


                                • Glossary


                                • Desk Marketplace


                                • MVP Corner


                                • Word of the Day



                                    Zoho Marketing Automation


                                            Manage your brands on social media



                                                  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 WorkDrive Resources



                                                                      Zoho Campaigns Resources

                                                                        Zoho CRM Resources

                                                                        • CRM Community Learning Series

                                                                          CRM Community Learning Series


                                                                        • Tips

                                                                          Tips

                                                                        • 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