Function-33: Create Accounts from Leads with all the data at the click of a button.

Function-33: Create Accounts from Leads with all the data at the click of a button.



Welcome back everyone!

Last week, we learnt how to send mass emails to specific groups of leads or contacts . This week, let's look at a custom function that lets you create accounts from leads with all the data.

Business scenario:

Opportunities come in strange ways. One day there might be no good leads, but the next day you might bag a million dollar deal. Or there might be a lot of deals with smaller figures from different leads. Either way, there's a lotta work for you. And by that, I mean gathering lead details, following up with them, documenting your interactions with them and so on. If there are multiple leads, you can imagine what you're gonna go through.

At times, leads would just become contacts and there are also times where leads would be from other companies. Zoho CRM offers you the provisions to automatically create a contact from a lead, but not an account. Wouldn't it save a lot of your work and time if an Account (company) record is created with all the details, interactions and information from a lead record?

Although it is conventional process to get a lead, create a contact and then add an account for the said lead, there might arise a situation where contacts are a section that are not required. This week's function is for those scenarios.

It works in the same way as Lead to Contact conversion, but just that it's Lead to Account.

Getting started with the custom function:
  1. Go to Setup > Customization > Modules > Deals > Links and buttons > Create new button.
  2. Provide a name for the button. For example: "Create Account from Lead". Add a description(optional).
  3. Select the placement of the button as View page.
  4. Select the action to be performed as "Writing function".
  5. Copy the code given below.
  6. Click “Edit arguments”.
  7. Enter the name as “leadId” and select the value as “Lead Id”.
  8. Click Save&Execute Script.
  9. Save the script.
  10. Select the profiles who can view this button.
  11. Click Save.

The script:

Code for Version 2.0 API:

leadDetails = zoho.crm.getRecordById("Leads", leadId.toLong());
accountmap = map();
accountmap.put(("Account_Name"), ifnull(leadDetails.get("Full_Name"),""));
accountmap.put("App_Out", ifnull(leadDetails.get("App Out"),""));
accountmap.put("Approved_Date", ifnull(leadDetails.get("Approved_Date"),""));
accountmap.put("Associated_MIDs", ifnull(leadDetails.get("Associated_MIDs"),""));
accountmap.put("Transaction_Fee", ifnull(leadDetails.get("Transaction_Fee"),""));
accountmap.put("Type_of_Ownership", ifnull(leadDetails.get("Type_of_Ownership"),""));
accountmap.put("Website", ifnull(leadDetails.get("Website"),""));
accountmap.put("Billing_Code", ifnull(leadDetails.get("Zip_Code"),""));
accountmap.put("Yelp", ifnull(leadDetails.get("Yelp"),""));
accountcreate = zoho.crm.create(("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",note.get("Note_Content"));
notemap.put("se_module","Accounts");
notecreate = zoho.crm.create("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.update("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.update("Events", ele2.get("id"), eventMap);
}
CallDetails = zoho.crm.getRelatedRecords("Calls", "Leads", leadId.toLong());
for each ele3 in CallDetails
{
callMap = map();
callMap.put("What_Id", newacctId);
callMap.put("se_module","Accounts");
UpdateCall = zoho.crm.update("Calls", ele3.get("id"), callMap);
}
return "Success";

Code for Version 1.0 API:

leadIdLong = input.leadId.toLong();
leadIdStr = input.leadId.toString();
leadDetails = zoho.crm.getRecordById("Leads", leadIdLong);
name = ((ifnull(leadDetails.get("First Name"),"")) + " ") + ifnull(leadDetails.get("Last Name"),"");
accountmap = map();
accountmap.put(("Account Name"), name);
accountmap.put("App Out", ifnull(leadDetails.get("App Out"),""));
accountmap.put("Approved Date", ifnull(leadDetails.get("Approved Date"),""));
accountmap.put("Associated MIDs", ifnull(leadDetails.get("Associated MIDs"),""));
accountmap.put("Average Monthly Processing", ifnull(leadDetails.get("Average Monthly Processing"),""));
accountmap.put("Processing", ifnull(leadDetails.get("Processing"),""));
accountmap.put("Processing Date", ifnull(leadDetails.get("Processing Date"),""));
accountmap.put("Rate Type", ifnull(leadDetails.get("Rate Type"),""));
accountmap.put("Type of Ownership", ifnull(leadDetails.get("Type of Ownership"),""));
accountmap.put("Website", ifnull(leadDetails.get("Website"),""));
accountmap.put("Billing Code", ifnull(leadDetails.get("Zip Code"),""));
accountmap.put("Yelp", ifnull(leadDetails.get("Yelp"),""));
accountcreate = zoho.crm.create(("Accounts"), accountmap);
newacctId = (accountcreate).get("Id");
RelNotes = zoho.crm.getRelatedRecords("Notes", "Leads", leadIdStr);
countVal = 0;
for each ele in RelNotes
{
countVal = (countVal + 1);
notemap = map();
notemap.put("entityId", newacctId);
notemap.put("Note Title", ifnull(ele.get("Title")," "));
notemap.put("Note Content", ifnull(ele.get("Note Content")," "));
notecreate = zoho.crm.create("Notes", notemap);
}
TaskDetails = zoho.crm.getRelatedRecords("Tasks", "Leads", leadIdStr);
for each ele1 in TaskDetails
{
TaskId = ele1.get("ACTIVITYID");
taskMap = map();
taskMap.put("SEID", newacctId);
taskMap.put("SEMODULE", ("Accounts"));
UpdateTask = zoho.crm.updateRecord("Tasks", TaskId, taskMap);
}
EventDetails = zoho.crm.getRelatedRecords("Events", "Leads", leadIdStr);
for each ele2 in EventDetails
{
eventId = ele2.get("ACTIVITYID");
eventMap = map();
eventMap.put("SEID", newacctId);
eventMap.put("SEMODULE", ("Accounts"));
UpdateEvent = zoho.crm.updateRecord("Events", eventId, eventMap);
}
CallDetails = zoho.crm.getRelatedRecords("Calls", "Leads", leadIdStr);
for each ele3 in CallDetails
{
callId = ele3.get("ACTIVITYID");
callMap = map();
callMap.put("SEID", newacctId);
callMap.put("SEMODULE", ("Accounts"));
UpdateCall = zoho.crm.updateRecord("Calls", callId, callMap);
}
}
return "Success";
----------------------------------------------------------------------------------------------------

Note:
  • The code is zoho.crm._getRecordById for Version 1.0 of APIs.
  • You can further customize by creating a custom field in leads module named "Account" or "Company". You can map this custom field to the Account name to create an account with the organization's name.
Found this useful? Try it out and let me know how it works! If you have questions, do not hesitate to ask! Share this with your team if you find it useful. Do check out other custom functions shared in this series here .

See you all next week with another interesting custom function. Ciao!

Update: As you must be aware, API V1.0 will be deprecated and support for version 1.0 API will be available only till Dec 31, 2018. Version 1.0 compatible Functions will continue to work until Dec 31, 2019. You're advised to migrated to API Version 2.0 at the earliest. Check this  announcement  for more. We've updated the post to include the Version 2.0 compatible Function.

    • Sticky Posts

    • How to reach the official Zoho Support channels and avoid fake ones.

      Dear Customers, Thanks a lot for choosing Zoho! Our applications are built to help achieve your day-to-day business goals. We are committed to engaging with you, to understand and develop solutions that enhance your productivity.  We are happy and ready to help you use our services effectively. Understanding and avoiding fake support Just like using popular bank names and financial applications for phishing purposes, using Zoho and claiming to be providing Zoho Support or services with false numbers
    • Function #35: Close all tasks associated with a lead and create a new task.

      Welcome back everyone! Last week, we learnt how to close all tasks of a deal depending upon the deal stage. This week, let's look at a custom function that lets you close all of the tasks associated with a lead while simultaneously creating a new task, like when you need to halt all progress towards a lead while the lead is not available at the moment but create a reminder task. Business scenario: The success of a company, in one way or another, is determined by the leads it gets. Each lead is just
    • Zoho CRM Webinar - Redesigning Daily User Experiences with Canvas

      <br> Your users across roles use the CRM for day-to-day tasks that are necessary. Whether they perform their tasks on time, the right way, or at all depends on a lot of factors, including User Experience. Many businesses struggle with rigid layouts,
    • Join us at the Canada ZUG Meetup: What’s New in Zoho CRM

      Hello Zoho Community! Start your year with fresh insights into Zoho CRM’s latest updates and tools. Whether you're a CRM beginner or a experienced user, this meetup is crafted to help you optimise your processes and leverage new features. Explore practical
    • CRM Hack #2: Automate sending of birthday greetings to your customers.

        Hello everyone! What sets you apart as a sales person is your ability to add that personal touch to your business relationship with your customers. Sending a gift on a special day, or leaving a note wishing them on their birthdays, are small, yet significant actions that show your customers that you care. And these are actions done without any expectations :) You must be engaging with a lot of customers and it is highly unlikely that they all are your friends on Facebook or some social channel,
    • Recent Topics

    • Forwarding

      How can I forward my Zoho account to my gmail account? Noël
    • Modular Permission Levels

      We need more modular Permissions per module in Books we have 2 use cases that are creating problems We need per module export permission we have a use case where users should be able to view the sales orders but not export it, but they can export other
    • Kaizen #157: Flyouts in Client Script

      Hello everyone! Welcome back to another exciting edition of our Kaizen series, where we explore fresh insights and innovative ideas to help you discover more and expand your knowledge!In this post, we'll walk through how to display Flyouts in Client Script
    • How get stock name from other column ?

      How get stock name from other column ? e.g. =STOCK(C12;"price") where C12 is the code of the stock
    • Adding a developer for editing the client application with a single user license

      Hi, I want to know that I as a developer I developed one application and handed over to the customer who is using the application on a single user license. Now after6 months customer came back to me and needs some changes in the application. Can a customer
    • Download an email template in html code

      Hello everyone, I have created an email template and I want to download it as html. How can i do that? I know you can do it via the campaigns-first create a campaign add the template and download it as html from there. But what if i don't want to create
    • Attachment is not included in e-mails sent through Wordpress

      I have a Wordpress site with Zeptomail Wordpress plugin installed and configured. E-mails are sent ok through Zeptomail but without the included attachment (.pdf file) Zeptomail is used to send tickets to customers through Zeptomail. E-Mails are generated
    • Upcoming Changes to the Timesheet Module

      The Timesheet module will undergo a significant change in the upcoming weeks. To start with, we will be renaming Timesheet module to Time Logs. This update will go live early next week. Significance of this change This change will facilitate our next
    • Best way to schedule bill payments to vendors

      I've integrated Forte so that I can convert POs to bills and make payments to my vendors all through Books. Is there a way to schedule the bill payments as some of my vendors are net 30, net 60 and even net 90 days. If I can't get this to work, I'll have
    • Cant update image field after uploading image to ZFS

      Hello i recently made an application in zoho creator for customer service where customers could upload their complaints every field has been mapped from creator into crm and works fine except for the image upload field i have tried every method to make
    • Billing Management: #4 Negate Risk Free with Advances

      In the last post, we explored how unbilled charges accumulate before being invoiced. But what happens when businesses need money before service begins? Picture this: A construction company takes on a $500,000 commercial building project expected to last
    • Zoho Mail CC and BCC not working

      Zoho Mail CC and BCC not working. I have tried multiple combinations amongst my domain aliases but emails sent as CC or BCC never arrive, not even to Spam. I have checked that the DNS is set up correctly in Cloudflare and have even received a DMARC report
    • Is there an equivalent to the radius search in RECRUIT available in the CRM

      We have a need to find all Leads and/or Contacts within a given radius of a given location (most likely postcode) but also possibly an address. I was wondering whether anyone has found a way to achieve this in the CRM much as the radius search in RECRUIT
    • Zoho CRM Inventory Management

      What’s the difference between Zoho CRM’s inventory management features and Zoho Inventory? When is it better to use each one?
    • Cannot Enable Picklist Field Dependency in Products or Custom Modules – Real Estate Setup

      Hello Zoho Support, I am configuring Zoho CRM for real estate property management and need picklist field dependency: What I’ve tried: I started by customizing the Products module (Setup > Modules & Fields) to create “Property Type” (Housing, Land, Commercial)
    • Get Workflow Metadata via API

      Is there a way to get metadata on workflows and/or custom functions via API? I would like to automatically pull this information. I couldn't find it in the documentations, but I'm curious if there is an undocumented endpoint that could do this. Moderation
    • Zoho Projects - Q2 Updates | 2025

      Hello Users, With this year's second quarter behind us, Zoho Projects is marching towards expanding its usability with a user-centered, more collaborative, customizable, and automated attribute. But before we chart out plans for what’s next, it’s worth
    • FSM setup

      So we have been tinkering with FSM to see if it is going to be for us. Now is the time to bite the bullet and link it to our zoho books and zoho crm. The help guides are good but it would really help if they were a bit more in depth on the intergrations.
    • Upcoming Updates to the Employees Module in Zoho Payroll (US)

      We've made a couple of updates to the Employees module in Zoho Payroll (latest version of the US edition). These changes will go live today. While creating an employee Currently, the Compensation Details section is part of the Basic Details step, where
    • Possible to Turn Off Automatic Notifications for Approvals?

      Hello, This is another question regarding the approval process. First a bit of background: Each of our accounts is assigned a rank based on potential sales. In Zoho, the account rank field is a drop-down with the 5 rank levels and is located on the account
    • ZOHO Creator subform link

      Dear Community Support, I am looking for some guidance on how to add a clickable link within a Zoho Creator subform. The goal is for this link to redirect users to another Creator form where they can edit the data related to the specific row they clicked
    • Allow Resource to Accept or Reject an Appointment

      I have heard that this can be done, is there any documentation on how?
    • Create new Account with contact

      Hi I can create a new Account and, as part of that process, add a primary contact (First name, last name) and Email. But THIS contact does NOT appear in Contacts. How can I make sure the Contact added when creating an Account is also listed as a Contact?
    • Custom Fonts in Zoho CRM Template Builder

      Hi, I am currently creating a new template for our quotes using the Zoho CRM template builder. However, I noticed that there is no option to add custom fonts to the template builder. It would greatly enhance the flexibility and branding capabilities if
    • Python - code studio

      Hi, I see the code studio is "coming soon". We have some files that will require some more complex transformation, is this feature far off? It appears to have been released in Zoho Analytics already
    • Sync desktop folders instantly with WorkDrive TrueSync (Beta)

      Keeping your important files backed up and accessible has never been easier! With WorkDrive desktop app (TrueSync), you can now automatically sync specific desktop folders to WorkDrive Web, ensuring seamless, real-time updates across devices. Important:
    • How To Insert Data into Zoho CRM Organization

      Hi Team I have this organization - https://crm.zoho.com/crm/org83259xxxx/tab/Leads I want to insert data into this Leads module, what is the correct endpoint for doing so ? Also I have using ZohoCRM.modules.ALL scope and generated necessary tokens.
    • Where can I get Equation Editor por Zoho Writer?

      I need to use Math Formulas in my document. Thank you.
    • Filtering repport for portal users

      Salut, I have a weird problem that I just cannot figure out : When I enter information as administrator on behalf of a "supplier" portal user (in his "inventory" in a shared inventory system), I can see it, "customer" portal users can see it, but the
    • I want to add my other zoho account in same pc

      why does zoho restrict me doing many things as i also want to add my second mail account bit its not allowing me to do that
    • Zoho Inventory. Preventing Negative Stock in Sales Orders – Best Practices?

      Dear Zoho Inventory Community, We’re a small business using Zoho Inventory with a team of sales managers. Unfortunately, some employees occasionally overlook stock levels during order processing, leading to negative inventory issues. Is there a way to
    • Sorten the domain of zoho mail ids

      I recently created zoho mail id and am quite excited with the features. But one issue ig nobody wanna type this big zohoaccounts.com I mean silly bold Suggestion zmail.com (sound gmail) (attraction) or some genz words looks cool
    • Request for Creating Multiple Email Accounts on One Mobile Number

      Dear Zoho Team, I am planning to shift all my work-related communication to Zoho Mail because of its reliability and features. For my work, I need to create 3–4 separate email accounts for different purposes. Could you please confirm if it is possible
    • BUTTONS SHOWN AS AN ICON ON A REPORT

      Hi Is there any way to create an action button but show it as an icon on a report please? As per the attached example? So if the user clicks the icon, it triggers an action?
    • Dropshipping Address - Does Not Show on Invoice Correctly

      When a dropshipping address is used for a customer, the correct ship-to address does not seem to show on the Invoice. It shows correctly on the Sales Order, Shipment Order, and Package, just not the Invoice. This is a problem, because the company being
    • RFQ MODEL

      A Request for quotation model is used for Purchase Inquiries to multiple vendors. The Item is Created and then selected to send it to various vendors , once the Prices are received , a comparative chart is made for the user. this will help Zoho books
    • Will zoho thrive be integrated with Zoho Books?

      title
    • Product Updates in Zoho Workplace applications | August 2025

      Hello Workplace Community, Let’s take a look at the new features and enhancements that went live across all Workplace applications this August. Zoho Mail Delegate Email Alias Now you can let other users send emails on your behalf—not just from your primary
    • Unable to send message; Reason:554 5.1.8 Email Outgoing Blocked

      Hi, I sent few emails and got this: Unable to send message; Reason:554 5.1.8 Email Outgoing Blocked And now I have few days since I cant send any email. Is there something wrong I did? Also can someone fix this please
    • Want to use Zoho Books in Switzerland. CHF support planned?

      Hi, We're a Swiss company using other Zoho suite software and I discovered Zoho Books and other accounting SaaS when looking for an accounting tool. Do you intend to cover Switzerland and CHF based accounting anytime soon? Roy
    • Next Page