What "Convert Lead" Means
In Zoho CRM, when you convert a lead:
It becomes a Contact.
Optionally, it can create an Account (Company) and a Deal (Potential).
The original Lead record is marked as converted.
Deluge supports this using the zoho.crm.convertLead() function.
lead_id = "123456789012345"; // Replace with your Lead ID
// Create a map for conversion details
conversion_map = Map();
conversion_map.put("overwrite", true); // optional, overwrite duplicates
// Convert the Lead
response = zoho.crm.convertLead(lead_id, conversion_map);
info response;
leadId = "123456789012345"; // You can use input.leadId if this runs from a button
// Fetch the lead record
lead_info = zoho.crm.getRecordById("Leads", leadId);
// Prepare conversion data
convert_map = Map();
// Optional overwrite
convert_map.put("overwrite", true);
// Build contact info
contact_data = Map();
contact_data.put("First_Name", lead_info.get("First_Name"));
contact_data.put("Last_Name", lead_info.get("Last_Name"));
contact_data.put("Email", lead_info.get("Email"));
contact_data.put("Phone", lead_info.get("Phone"));
convert_map.put("contact", contact_data);
// Build account info (optional)
if(lead_info.get("Company") != null)
{
account_data = Map();
account_data.put("Account_Name", lead_info.get("Company"));
convert_map.put("account", account_data);
}
// Convert the lead
try
{
response = zoho.crm.convertLead(leadId, convert_map);
info response;
}
catch (e)
{