// Domailfix for Zoho CRM: when a lead has no email, find it from First Name + Last Name + Website. // SETUP (once): // 1. Setup > Modules and Fields > Leads: add fields "Email Status" (Single Line) and // "Email Score" (Number). Their API names must be Email_Status and Email_Score. // 2. Setup > Developer Space > Variables: new variable domailfix_api_key = your Domailfix // API key (dmf_..., from your Domailfix account page). // 3. Setup > Developer Space > Functions > New Function (Automation). Edit Arguments: add // leadId (Int). Paste this whole file and Save. // 4. Setup > Automation > Workflow Rules > New rule on Leads, when a record is Created // (or Edited, with "Email is modified"). Instant action: Function > this function, // map leadId to Leads - Lead Id. Save. // Each check uses your Domailfix credits. For Contacts, change "Leads" to "Contacts". lead = zoho.crm.getRecordById("Leads", leadId); if(ifnull(lead.get("Email"), "") != "") { return; } fullName = (ifnull(lead.get("First_Name"), "") + " " + ifnull(lead.get("Last_Name"), "")).trim(); website = ifnull(lead.get("Website"), "").trim(); if(fullName == "" || website == "") { return; } apiKey = zoho.crm.getOrgVariable("domailfix_api_key"); headerMap = Map(); headerMap.put("X-API-Key", apiKey); headerMap.put("Content-Type", "application/json"); body = Map(); body.put("name", fullName); body.put("website", website); response = invokeurl [ url :"https://domailfix.achivix.com/api/find" type :POST parameters:body.toString() headers:headerMap ]; found = ifnull(response.get("email"), ""); updateMap = Map(); updateMap.put("Email_Status", ifnull(response.get("status"), "not_found")); updateMap.put("Email_Score", ifnull(response.get("score"), 0)); if(found != "") { updateMap.put("Email", found); } result = zoho.crm.updateRecord("Leads", leadId, updateMap); info result;