For many businesses, the standard lead conversion process—creating a contact, an account, and, optionally, a deal—may not align with their workflow. Some sales teams need the flexibility to create an account directly from a lead record while carrying over specific field values and all associated activities such as notes, tasks, and events.
Without this capability, sales reps must create the account manually, re-enter field data, and reassign each related activity individually. This process is time-consuming, error-prone, and disrupts the flow of the sales pipeline. What if you could create an account directly from a lead record and copy its field data, notes, and activities with a single click? This solution addresses that gap.
You can add a custom button to the lead details page and associate it with a Deluge function. When clicked, the button automatically creates an account from the lead, copies specific field values, duplicates related notes under the new account, and reassigns existing tasks and events to the newly created account—all in a single action. Read on to learn more.
Permissions and availability
- Users with the Modules Customization permission can create custom buttons.
- Users with the Manage Extensibility permission can write custom functions.
- Users with the Manage Sandbox permission can manage the sandbox.
Requirements
- Create and link the button with the custom function, as detailed in the "Create a button" section below. Learn more
- Test the function in a sandbox before deploying it in your production environment. Learn more
Create a button
Follow the steps below to create a custom button linked to a function.
- Navigate to Setup > Customization > Modules and Fields > Leads > Buttons > Create New Button.
- Provide a name for the button. For example: "Create Account".
Add a description (optional). - Choose the layouts in which you want the button to be placed in.
- Specify the button's placement as In Record and its position on the page as Details.
- Select the action to be performed as Writing Function.
- Provide a name and display name for the function, then click Create.
- In the Deluge script editor, do the following:
- Copy and paste the code provided below.
- Click Edit Arguments.
- Enter the name as leadId and select the value as Leads - Lead Id, then click Save.
- Save the function.
- Turn on button accessibility for CRM Users.
- Select the profiles who can view this custom button.
- Click Save.
The code
leadDetails = zoho.crm.getRecordById("Leads", leadId.toLong());
accountmap = map();
accountmap.put("Account_Name", ifnull(leadDetails.get("Company"),""));
accountmap.put("Website", ifnull(leadDetails.get("Website"),""));
accountmap.put("Email", ifnull(leadDetails.get("Email"),""));
accountcreate = zoho.crm.createRecord("Accounts", accountmap);
newacctId = accountcreate.get("id");
RelNotes = zoho.crm.getRelatedRecords("Notes", "Leads", leadId.toLong());
for each ele in RelNotes
{
notemap = Map();
notemap.put("Parent_Id",newacctId);
notemap.put("Note_Content",ele.get("Note_Content"));
notemap.put("se_module","Accounts");
notecreate = zoho.crm.createRecord("Notes",notemap);
info notecreate;
}
TaskDetails = zoho.crm.getRelatedRecords("Tasks", "Leads", leadId.toLong());
for each ele1 in TaskDetails
{
taskMap = map();
taskMap.put("What_Id", newacctId);
taskMap.put("se_module","Accounts");
UpdateTask = zoho.crm.updateRecord("Tasks", ele1.get("id"), taskMap);
}
EventDetails = zoho.crm.getRelatedRecords("Events", "Leads", leadId.toLong());
for each ele2 in EventDetails
{
eventMap = map();
eventMap.put("What_Id", newacctId);
eventMap.put("se_module","Accounts");
UpdateEvent = zoho.crm.updateRecord("Events", ele2.get("id"), eventMap);
}
return "Account created successfully";Notes
- Make sure to use the accurate API names for their corresponding fields (e.g., "Company") in the code snippet. Learn more
- The code snippet contains sample fields that you can customize to suit your business requirements.
- The fields on the left side (after mp.put) are the destination fields, while those on the right are the source fields.
- The function duplicates related notes by creating new note records under the account, while existing tasks and events are updated to reference the new account.
- The function does not delete or convert the lead record after the account is created.
- The code above demonstrates how to automatically create an account from a lead, copy specific field values, duplicate related notes, and reassign tasks and events to the new account. You can adapt this code for other modules by modifying the module names, field mappings, and other relevant parameters to suit your business requirements.
Tips
- Configure and test the button in a sandbox to ensure that further development doesn't disrupt your production environment.
Test the solution
- Navigate to the Leads module and select the required list view.
- Open a lead record that has related notes, tasks, and events associated with it.
- On the Lead Details page, click the "Create Account" button you added to the top-right area.
- Confirm the button returns the message "Account created successfully".
- Verify the following:
- A new Account record is created with the lead's company name as the account name.
- The fields mapped in the code snippet are populated correctly in the new account.
- All notes from the lead are duplicated under the new account's related notes.
- All tasks and events previously associated with the lead are reassigned to the new account.
Note: Calls will not be reassigned to the new account.
Did you find this useful? Try it out and let us know how it works. Share this with your team if they'd benefit from it! If you have questions, please don't hesitate to contact us.
More info
- ModuleLeads
- Trigger PointCustom Button
- EditionEnterprise and above
- ComplexityLow
- Implementation Time15 minutes

Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST