Zoho times out on searchRecords request
Hi
I am using a block of Deluge code to check all my contacts that dont have a scheduled call for them and then if they don't sheduling a call. I have 6000 contacts with about 70 percent of them already having scheduled calls. Its the 30 percent that dont that I am trying to get and fix.
I am getting inconsistent results with the searchrecords function, it also isn't assigning to all the contacts that dont have a scheduled call. It is also adding a scheduled call to a contact that alreasy has one, and lastly the most frustrating part is that ZOHO times out.
I am not entirely sure how the searchrecords command actually works in Zoho, does it just check the same records over and over again every time you run it and that's why it is timing out and not finding new records that don't have a scheduled call?
Could you also advise if the code below is actually the most effective way to do this?
- loop = {1,2,3,4,5.6,7,8,9,10};
- Contactswithoutcall = List();
- for each ele in loop
- {
- MyContacts = zoho.crm.searchRecords("Contacts","(Owner:equals:4775614000000386180)",1,200);
- if(MyContacts.size() == 0)
- {
- break;
- }
- // Get contacts that dont have a scheduled call
- for each rec in MyContacts
- {
- val = "";
- relcalls = zoho.crm.getRelatedRecords("Calls","Contacts",rec.get("id"));
- if(relcalls.size() > 0)
- {
- for each call in relcalls
- {
- ctime = call.get("Call_Start_Time").toTime("yyyy-MM-dd'T'HH:mm:ss");
- if(ctime > now)
- {
- val = "Yes";
- }
- }
- }
- if(val == "")
- {
- Contactswithoutcall.add(rec.get("id"));
- }
- }
- }
- // info " Contact List;" + Contactswithcall;
- info "Account Count : " + Contactswithoutcall.size();
- for each contactelement in Contactswithcall
- {
- contactDetails = zoho.crm.getRecordById("Contacts",contactelement);
- // info contactDetails;
- createdtime = zoho.currentdate.toTime("yyyy-MM-dd'T'HH:mm:ss").addBusinessDay(2);
- mp = Map();
- acctname = ifnull(contactDetails.get("Account_Name"),"");
- if(acctname != "")
- {
- acctid = acctname.get("id");
- accountDetails = zoho.crm.getRecordById("Accounts",acctid);
- mp.put("$se_module","Accounts");
- mp.put("What_Id",acctid);
- }
- mp.put("Subject","Prospecting");
- mp.put("Owner",ifnull(contactDetails.get("Owner"),"").get("id"));
- mp.put("Call_Type","Outbound");
- mp.put("Who_Id",contactDetails);
- mp.put("Call_Start_Time",createdtime.toString("yyyy-MM-dd'T'HH:mm:ss+02:00"));
- mp.put("$which_call","ScheduleCall");
- create = zoho.crm.createRecord("Calls",mp);