Trying to copy Active Leads to a Custom Module called Dead Leads

Trying to copy Active Leads to a Custom Module called Dead Leads

Hi, I am trying to code when the "Active Lead Status" field is changed to "Dead", a copy of the record should be created in the "Dead Leads" module while keeping the original lead in "Active Leads." I am using the following code but I keep getting the error code " Improper code format Correct format : <return_type> <category>.<function_name>(<type> <arg1>, <type> <arg1>,...<type> <arg50>){ <code> }" . Any help would be appreciated.

Code Pasted:

// Function to copy an Active Lead to Dead Leads when "Active Lead Status" is set to "Dead"
void automation.CopyToDeadLeads(int leadId)
{
    // Fetch the Active Lead record using the provided ID
    leadDetails = zoho.crm.getRecordById("Active_Leads", leadId);

    // Ensure the record exists before proceeding
    if(leadDetails.containsKey("id"))
    {
        // Prepare data for Dead Leads module
        Map deadLeadData = Map();
        deadLeadData.put("Dead_Lead_Name", leadDetails.get("Last_Name"));
        deadLeadData.put("Units", leadDetails.get("Units"));
        deadLeadData.put("Land_Size", leadDetails.get("Land_Size"));
        deadLeadData.put("Asking_Price", leadDetails.get("Asking_Price"));
        deadLeadData.put("Project_Type", leadDetails.get("Project_Type"));
        deadLeadData.put("Broker", leadDetails.get("Broker"));
        deadLeadData.put("Company", leadDetails.get("Company"));
        deadLeadData.put("Development_Lead", leadDetails.get("Development_Lead"));
        deadLeadData.put("Dead_Lead_Status", leadDetails.get("Active_Lead_Status")); // Ensuring correct field mapping
        deadLeadData.put("Description", leadDetails.get("Description"));
        deadLeadData.put("Street", leadDetails.get("Street"));
        deadLeadData.put("City", leadDetails.get("City"));
        deadLeadData.put("State", leadDetails.get("State"));
        deadLeadData.put("Zip_Code", leadDetails.get("Zip_Code"));

        // Insert into Dead Leads module
        Map createResponse = zoho.crm.createRecord("Dead_Leads", deadLeadData);

        // Log response for debugging
        info createResponse;
    }
}

    • Sticky Posts

    • Kaizen #198: Using Client Script for Custom Validation in Blueprint

      Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
    • Kaizen #226: Using ZRC in Client Script

      Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this
    • Kaizen #222 - Client Script Support for Notes Related List

      Hello everyone! Welcome to another week of Kaizen. The final Kaizen post of the year 2025 is here! With the new Client Script support for the Notes Related List, you can validate, enrich, and manage notes across modules. In this post, we’ll explore how
    • Kaizen #217 - Actions APIs : Tasks

      Welcome to another week of Kaizen! In last week's post we discussed Email Notifications APIs which act as the link between your Workflow automations and you. We have discussed how Zylker Cloud Services uses Email Notifications API in their custom dashboard.
    • Kaizen #216 - Actions APIs : Email Notifications

      Welcome to another week of Kaizen! For the last three weeks, we have been discussing Zylker's workflows. We successfully updated a dormant workflow, built a new one from the ground up and more. But our work is not finished—these automated processes are