I am trying to write a script which will need to find a particular lead OR contact (by email). My current approach is to get all leads, then iterate over the collection until the appropriate one is found.
- //get the appropriate category
- loc = zoho.crm.getRecords("Leads"); //leads or contacts
- if (wasContact) {
- loc = zoho.crm.getRecords("Contacts");
- }
- //find by email
- oldItem = null;
- for each assoc item in loc {
- if (item.email == old.doctorEmail && item.pr_account == true) {
- oldItem = item;
- break;
- }
- }
I have tried variations on the for each statement (assoc, index, nothing).
However, I receive an error "Form loc does not exist in application", or with the variations previously mentioned, other messages.
What is the best way to approach this?