Hi folks,
We all have customers (contacts) that leave their employeer (account). Currently, there is no way to archive these contact records so to not show up in searches. Worse, if you delete them, emails and activities associated with their activities are no longer available.
We've got over 1000 such contacts. We hard them with a custom bool field called "has left" but they still remain in all manner of processes and searches we really do not want them in.
To overcome this problem, I create a button with a Deluge function that:
1. sets the contact record 'has left' field to true
2. appends their first and last names with Z> so they will no longer show up in (most) searches
3. removes then from mailing lists (we have a custom field we use to segment contacts in campaigns
4. sets their email opt out field to true (we don't want them getting emails any more!)
5. changes their customer status flag 'rasaccess'
6. removes any OPEN tasks associated with the contact
The following Deluge code can be used as a button. It is not perfect, and I am going to add some error checking, but it should give others ideas on how to create a work-around for the lack of contact archival in Zoho CRM.
contactMap = zoho.crm.getRecordById("Contacts",ContactId);
firstName = "Z>".concat(contactMap.get("First_Name"));
lastName = "Z>".concat(contactMap.get("Last_Name"));
emailOptOut = true;
mailingLists = "";
rasAccessLevel = "Nil";
linkinLink = "";
updateMap = {"Has_Left":true,"First_Name":firstName,"Last_Name":lastName,"Email_Opt_Out":emailOptOut,"Mailing_Lists":mailingLists,"RAS_Access_Level":rasAccessLevel,"LinkedIn_Link":linkinLink};
// clear out open tasks
openTasksList = zoho.crm.getRelatedRecords("Tasks","Contacts",ContactId);
// info openTasksList ;
info openTasksList.size();
for each taskMap in openTasksList
{
taskStatus = taskMap.get("Status");
info taskStatus;
if(taskStatus != "Completed")
{
// delete the ask!
// note, deleting requires a lower level API call within Zoho - this is done via the 'invokeConnector' call
deleteRecordMap = {"module":"Tasks","id":taskMap.get("id")};
deleteResp = zoho.crm.invokeConnector("crm.delete",deleteRecordMap);
info deleteResp;
}
}
//
result = zoho.crm.updateRecord("Contacts",ContactId,updateMap);
info result;
return "Contact now marked as Has Left. Any open tasks have been removed.";