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

    • Restore lost Invoice!

      Some time ago I tried to Upgrade from Invoice to Books. I not upgraded and staid n Invoice. Now i tried again and first i deleted the old trial of books. But now all is gone, PLEASE HELP!! i have no backup and i have to have at least 7 years data retention by law. 
    • Zoho Desk Down

      Not loading
    • lookup and integrated forms

      I might be misunderstanding things but I wanted to integrate our zoho crm contacts into creator. I imagined that when I used the integration it would mirror into creator. It did brilliant. BUT We have a ticket form in creator that we want to use a lookup
    • Partially receive PO without partial Bill?

      Most of our inventory is pre-paid. Let's say we purchase 30 pieces of 3 different items for a total of 90 pieces. It is common for our supplier to send us the items as they are ready. So we will receive 30 pieces at a time. How can I partially receive
    • 2 users editing the same record - loose changes

      Hello, I'm very new to Zoho so apology if this has been addressed somewhere i can't find. I have noticed the following: If we have 2 users put an inventory item in edit mode at the same time: say user1 click on edit and user2 while user1 is still in edit,
    • How to get the Dashboard page to be the first page when you open the app

      So when it opens on a tablet or phone it opens on the welcome page, thanks.
    • How I set default email addresses for Sales Orders and Invoices

      I have customers that have different departments that handle Sales Orders and Invoices. How can i set a default email for Sales Orders that's different than the default email for Invoices? Is there a way I can automate this using the Contact Persons Departments
    • Adding hyperlinks in CRM emails time automatically

      It may just be me, but when I am writing an email to a lead, I find inserting a hyperlink very time consuming. Granted, I can use templates but there are a ton of scenarios where I might want to put a link in to an website that wouldnt require me to go though the effort of creating a template.  Ideally, the crm would identify that I that a string of text is a URL and insert the hyperlink automatically, just like microsoft outlook or gmail. Has anyone else had this same experience and found a way
    • Notes Attachments

      Two things it would be nice to have the attachment size the same as the attachments sections and it would be nice to be able to attach links like you can in the attachments section. Thank you
    • Zoho Sheet - Desktop App or Offline

      Since Zoho Docs is now available as a desktop app and offline, when is a realistic ETA for Sheet to have the same functionality?I am surprised this was not laucned at the same time as Docs.
    • Formula fields not refreshing until page is reloaded

      I need help/advice about the formula fields and how I can refresh the information in real-time. We have two formula fields on our deals page which show calculated prices: One formula is in a subform which calculates the subform total + 1 other field amount
    • How can I setup Zoho MCP with Chat GPT

      I can set up custom connections with Chat GPT but I cat an error when I try to set it up. The error is: "This MCP server can't be used by ChatGPT to search information because it doesn't implement our specification: search action not found" Thoughts?
    • Export Invoices to XML file

      Namaste! ZOHO suite of Apps is awesome and we as Partner, would like to use and implement the app´s from the Financial suite like ZOHO Invoice, but, in Portugal, we can only use certified Invoice Software and for this reason, we need to develop/customize on top of ZOHO Invoice to create an XML file with specific information and after this, go to the government and certified the software. As soon as we have for example, ZOHO CRM integrated with ZOHO Invoice up and running, our business opportunities
    • API ZOHO CRM Picket list with wrong values

      I am using Zoho API v.8. with python to create records in a custom module named "Veranstaltung" in this custom module I've got a picket list called "Email_Template" with 28 Values. I've added 8 new values yesterday, but if I try to use on of those values
    • Group Emails

      I have synced Zoho CRM to Campaigns but there are certain email not synced. showing it is Group Emails, but this email ids belongs to different individuals. please provide a solution as i nedd to sync the same.
    • Enable Password Import option in ulaa browser

      Dear Ulaa Team, I noticed that the Ulaa Password Manager currently offers an option to export passwords, but not to import them. This limitation poses a challenge for users like me who have stored numerous credentials in browsers like Chrome. Manually
    • "Is Zoho CRM customer" vs "Is linked with Zoho CRM"

      Recently while building a Flow, I was setting up a Decision action following a Zoho Invoice Fetch record action. There were 2 choices that I had not seen as something I could manually action in Zoho Invoice: "Is Zoho CRM customer" and "Is linked with
    • Client Script | Update #13 - Introducing ZRC: Simplified HTTP request library

      Hello Developers! Are you tired of juggling different methods to make API calls? Are you confused with multiple syntaxes and version restrictions? Have you ever wished for one simple way to make all API calls in CRM? We heard you :) Here comes ZRC (Zoho
    • Selection Filed for Data Export section

      Hi FSM Team, I hope you are all doing well. I would like to share an idea for future development based on my experience. Currently, in FSM, we can only download up to 5,000 records at a time. If the development team could add a selection option to choose
    • Text wrap column headers in reports?

      Is it possible to auto wrap column headers so that a longer multi-word header displays as two lines when the column is narrower than the width of the header title?
    • What if I dont see contacts on the left side list

      My CRM does not show the contacts tab. In order to create list this is needed and I cant find it.
    • Comments Vs. Replies

      I'm curious as to the difference between a "Reply" and a "Comment" on a ticket. It appears that "Replies" are what's used to determine response time SLA's and there are also used to automatically re-open tickets. I'm just trying to understand the key differences so I can educate both our clientele and our back-end users on which function/feature to use to better improve the ticket lifecycle. If anyone has any insight it would be appreciated. Thanks!
    • Transitioning to API Credits in Zoho Desk

      At Zoho Desk, we’re always looking for ways to help keep your business operations running smoothly. This includes empowering teams that rely on APIs for essential integrations, functions and extensions. We’ve reimagined how API usage is measured to give
    • Add Custom Reports To Dashboard or Home Tab

      Hi there, I think it would be great to be able to add our custom reports to the Home Tab or Dashboards. Thanks! Chad
    • Resetting auto-number on new year

      Hi everyone! We have an auto-number with prefix "D{YYYY}-", it generates numbers like D2025-1, D2025-2, etc... How can we have it auto-reset at the beginning of the next year, so that it goes to D2026-1? Thanks!
    • Microsoft Phone Link

      Does anyone know if you can use Microsoft Phone Link to make calls through Zoho?
    • Voip Phone system that integrates with Zoho

      Just checking to see if anyone could tell me what phone system they are using with Zoho that is on the list of systems that integrate with Zoho.  I use Vonage and have been with them for quite a few years but their service has really gone down hill and
    • Removing Related Modules Lookup Fields Assignment / Relationship

      Issue: When creating a related list, I accidently selected module itself creating a circle reference. See attached. Situation: I wish to relating a custom module called "Phone Calls" to Leads and Contacts. Outcome: 1) I either want to remove the this
    • [Product Update] TimeSheets module is now renamed as Time Logs in Zoho Projects.

      Dear Zoho Analytics customers, As part of the ongoing enhancements in Zoho Projects, the Timesheets module has been renamed to Time Logs. However, the module name will continue to be displayed as Timesheets in Zoho Analytics until the relevant APIs are
    • Kaizen #210 - Answering your Questions | Event Management System using ZDK CLI

      Hello Everyone, Welcome back to yet another post in the Kaizen Series! As you already may know, for the Kaizen #200 milestone, we asked for your feedback and many of you suggested topics for us to discuss. We have been writing on these topics over the
    • Can you prevent closing Ulaa window when the last tab is closed (inadvertently)?

      Most browsers have started to bring this feature in to prevent closing their windows when the last tab is closed (inadvertently). I hope Ulaa should get this in too.
    • Seriously - Create multiple contacts for leads, (With Company as lead) Zoho CRM

      In Zoho CRM, considering a comapny as a lead, you need us to allow addition of more than one contact. Currently the Lead Section is missing "Add contact" feature which is available in "Accounts". When you know that a particular lead can have multiple
    • can I link a contacts to multiple accounts

      can I link a contacts to multiple accounts
    • Rotate an Image in Workdrive Image Editor

      I don't know if I'm just missing something, but my team needs a way to rotate images in Workdrive and save them at that new orientation. For example one of our ground crew members will take photos of job sites vertically (9:16) on his phone and upload
    • Free webinar! Digitize recruitment and onboarding with Zoho Sign and Zoho Recruit

      Hello, Tired of being buried in onboarding paperwork? With the integration between Zoho Sign and Zoho Recruit, a powerful applicant tracking system, you can digitize and streamline the entire recruitment and onboarding process, all from one platform.
    • is it possible to add more than one Whatsapp Phone Number to be integrated to Zoho CRM?

      so I have successfully added one Whatsapp number like this from this User Interface it seems I can't add a new Whatsapp Number. I need to add a new Whatsapp Number so I can control the lead assignment if a chat sent to Whatsapp Phone Number 1 then assign
    • Open Activities view.

      I really like the new views for the open and closed activities inside the deals. But when you are in the tab view instead of the column view you can only complete and edit the open activity there isn't the 3 dot option to be able to delete the activ
    • Potentially Outdated and Vulnerable Chromium Engine Installed by Ulaa Browser Installer

      I just installed Ulaa Browser a few minutes ago. Whats My Browser page shows I am using an outdated Chromium engine meaning I might be vulnerable for security exploits that might have got fixed in the new version.
    • Potentially hardcoded list of Browsers to import from (after Ulaa Setup)

      I have just installed Ulaa Browser and found that the list of browser to import data is potentially hardcoded ones rather than looking at the system. I do not have FF, IE and Edge is not my default itself. I would appreciated if Ulaa detected my browsers
    • From Layout to Code: Finding Custom Field IDs in Zoho Projects.

      Hello everyone! Ever found yourself wondering how to get the API names and IDs of custom fields in Zoho Projects while working on custom functions? Here’s a simple and effective way to do it! This method makes it super easy to locate the right field details
    • Next Page