It's common for salespeople to convert a lead into an account accidentally. There are also situations where the conversion is intentional. However, it has been determined that the deal will likely take longer, and until then, you want to keep track and nurture the account as a lead. In all these situations, you wish to convert the account back into a lead, but find that your CRM's interface doesn't offer an option to do so.
Well, we have you covered. You can achieve this using a low-code custom function that helps you convert an account into a lead and delete the existing account record by clicking a single button. You also have the option to convert account records one by one, or select multiple records and convert them all at once.
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 Button" section below. Learn more
- Test the workflow rule in a sandbox before deploying it in your production environment. Learn more
Create a button
To begin, create a custom button that when clicked will convert an account into a lead and delete the existing account record.
- Navigate to Setup > Customization > Modules and Fields > Accounts > Buttons > Create New Button.
- Provide a name for the button. For example: "Convert to lead".
Add a description (optional). - Choose the layout(s) you want the button to be placed.
- 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, and click Create.
- In the Deluge script editor, do the following:
- Copy and paste the code provided below.
- Click Edit Arguments.
- Enter the name as acctId, select the value as Accounts - Account Id, then click Save.
- Save the function.
- Select the profiles who can view this custom button.
- Click Save.
The code
acctinfo = zoho.crm.getRecordById("Accounts",acctId.toLong());
mp = Map();
mp.put("Last_Name",acctinfo.get("Account_Name"));
mp.put("Owner",acctinfo.get("Owner").get("id"));
mp.put("Company",acctinfo.get("Account_Name"));
mp.put("Lead_Source",ifnull(acctinfo.get("Lead_Source"),""));
mp.put("Description",ifnull(acctinfo.get("Description"),""));
mp.put("Email",ifnull(acctinfo.get("Email"),""));
mp.put("LinkedIn",ifnull(acctinfo.get("LinkedIn"),""));
mp.put("Mobile",ifnull(acctinfo.get("Mobile"),""));
mp.put("Phone",ifnull(acctinfo.get("Phone"),""));
mp.put("Zip_Code",ifnull(acctinfo.get("Billing_Code"),""));
mp.put("State",ifnull(acctinfo.get("Billing_State"),""));
mp.put("Street",ifnull(acctinfo.get("Billing_Street"),""));
create = zoho.crm.createRecord("Leads",mp);
info create;
//Delete the account record
deleteResp = zoho.crm.invokeConnector("crm.delete",{"module":"Accounts","id":acctId});
info deleteResp;
return "success";
Notes
- Make sure to use the accurate API names for their corresponding fields in the code snippet. Learn more
- Converting an account record into a lead will result in the deletion of the account record and potential data loss. For example, it will move all related records, such as activities, contacts, deals, quotes, sales orders, invoices, and cases, to the Recycle Bin along with the account.
- Remove the last four lines in the code snippet above to avoid deleting the account record.
Test the solution
- In the Accounts module, click on a particular account you want to convert back to a lead.
- Click the custom button you've created in the steps above.
- Check whether a new lead record has been created with the account details and whether the current account record has been deleted and moved to the recycle bin.
- Make sure that all account information is accessible in the lead record.
Idea
Would you like to convert multiple accounts back into leads using the mass actions menu? If yes, then use the code snippet provided below instead.
accIdsList = acctId.toList("|||");
for each accIdStr in accIdsList
{
acctId = accIdStr;
acctinfo = zoho.crm.getRecordById("Accounts",acctId.toLong());
mp = Map();
mp.put("Last_Name",acctinfo.get("Account_Name"));
mp.put("Owner",acctinfo.get("Owner").get("id"));
mp.put("Company",acctinfo.get("Account_Name"));
mp.put("Lead_Source",ifnull(acctinfo.get("Lead_Source"),""));
mp.put("Description",ifnull(acctinfo.get("Description"),""));
mp.put("Email",ifnull(acctinfo.get("Email"),""));
mp.put("LinkedIn",ifnull(acctinfo.get("LinkedIn"),""));
mp.put("Mobile",ifnull(acctinfo.get("Mobile"),""));
mp.put("Phone",ifnull(acctinfo.get("Phone"),""));
mp.put("Zip_Code",ifnull(acctinfo.get("Billing_Code"),""));
mp.put("State",ifnull(acctinfo.get("Billing_State"),""));
mp.put("Street",ifnull(acctinfo.get("Billing_Street"),""));
create = zoho.crm.createRecord("Leads",mp);
info create;
deleteResp = zoho.crm.invokeConnector("crm.delete",{"module":"Accounts","id":acctId});
info deleteResp;
}
return "success";
Note
- When creating the button, select its placement as List View - Mass Action Menu.
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
- ModuleAccounts
- Trigger PointCustom Button
- EditionEnterprise and above
- ComplexityMedium
- Implementation Time30 minutes
Looking for a custom solution?
Contact us, we will help enhance your productivity at lightning speed.
SUBMIT REQUEST