Customize deal name created upon lead conversion

Convert a lead and create a deal in the name of the contact with the click of a button.

When you convert a lead, it creates a contact and an account automatically. Additionally, you have the option to create a new deal for the contact. This deal is typically named after the account associated with the contact. However, what if you would like to name it using the contact's title and last name, such as "Mr. Jackson"? It could assist you in tracking multiple deals and simplify locating specific ones in the future.

Using functions, you can convert a lead and create a deal in the name of the contact with the click of a button. Remember that the function cannot be triggered via a workflow rule, so you must place the button on the list view page of the Leads module in the desired order.

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

  1. Navigate to Setup > Customization > Modules and Fields > Leads > Buttons > Create New Button.
  2. Provide a name for the button. For example: "Convert and Create Deal".
    Add a description (optional).
  3. Choose the layout(s) you want the button to be placed.
  4. Specify the button's placement as In Record and its position on the page as Details.
  5. Select the action to be performed as Writing Function.
  6. Provide a name and display name for the function and click Create.
  7. In the Deluge script editor, do the following:
    1. Copy and paste the code provided below.
    2. Click Edit Arguments.
    3. Enter the name as leadId and select the value as Leads - Lead Id.
    4. Save the function.
  8. Select the profiles who can view this custom button.
  9. Click Save.
Create Button

The code

Code Copied
resp = zoho.crm.getRecordById("Leads",leadId.toLong());
customMap = Map();
customMap.put("Deal_Name",resp.get("Last_Name") + " - " + resp.get("Designation"));
customMap.put("Description",ifnull(resp.get("Description"),""));
customMap.put("Lead_Source",ifnull(resp.get("Lead_Source"),""));
convert = zoho.crm.convertLead(leadId,{"notify_lead_owner":true,"notify_new_entity_owner":true,"Deals":customMap});
info convert;
return "success";

Notes

  • Make sure to use the accurate API names for their corresponding fields in the code snippet. Learn more
  • The above script is an example of creating a deal using a contact's title and last name when converting a lead. By customizing the field name and parameters, you can modify this code to name the deal after a different field or value.

Tip

  • Configure and test the function in a sandbox to ensure that further development doesn't disrupt your production environment.

Test the solution

  1. Click the Leads module and select the required list view.
  2. Open a lead record you want to convert.
  3. On the Lead Details page, click the button you added to the view page in the top-right area. 
    The lead will be converted.
  4. Check whether a new contact, account, and deal have been created for the lead. Additionally, confirm if the deal has been named after the contact's title and last name.

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
  • ComplexityMedium
  • Implementation Time30 minutes

Features used in the solution

Custom ButtonDeluge ScriptSandbox
Story Image

Looking for a custom solution?

Contact us, we will help enhance your productivity at lightning speed.

SUBMIT REQUEST

Developers: Share your solution with our community!