Convert Lead

Convert Lead

Description

The zoho.crm.convertLead task is used to convert a lead into a contact, deal, and account in Zoho CRM.

Syntax

<response> = zoho.crm.convertLead(<lead_id>,<values>);

where,

ParamsDescriptionData type

<response>

specifies the response message returned by Zoho CRM. It represents the IDs of the new records created in Contacts, Deals, and Accounts module against its respective API names.

MAP

<lead_id>

specifies the record ID of the lead that needs to be converted. The record ID can be obtained from the response of Get Records task.

BIGINT

<values>

specifies the input value to the task. The possible keys of the input value can be found here.

Note: Refer this for the instructions to get API names of the CRM modules and fields.

MAP


Example 1

The following script converts the lead with ID - 2303XXXXXXXXXXXXXXX, and creates a new record in Contacts, Deals, and Accounts module.

 deal_values = Map();
 deal_values.put("Deal_Name","Jake");
 deal_values.put("Closing_Date","2018-12-06");
 deal_values.put("Stage","Closed Won");
 response = zoho.crm.convertLead(2303XXXXXXXXXXXXXXX,{"Deals":deal_values});

where,

response
is the KEY-VALUE response returned by Zoho CRM, which represents the IDs of the new records created in Contacts, Deals, and Accounts module
2303XXXXXXXXXXXXXXX
is the TEXT that represents the ID of the lead that needs to be converted
"Deals"
is the key of TEXT data type which represents the values of the new record to be created in the Deals Module
 deal_values 
is the KEY-VALUE variable that holds the additional values that are required to create a new record in the Deals Module

Example 2

The following script converts the lead with ID - 2303XXXXXXXXXXXXXXX and associates it to the specified existing account and contact. Here,

  • Since the overwrite key is set to true, the specified account and contact are overwritten with the data of the converting lead.

  • No record is created in the Deals module, as the additional values required for creating a deal are not provided.

 values_map = Map();
 values_map.put("overwrite",true);
 values_map.put("Accounts","2303XXXXXXXXXXXXXXX");
 values_map.put("Contacts","2303XXXXXXXXXXXXXXX");
 response = zoho.crm.convertLead(2303XXXXXXXXXXXXXXX,values_map);

where,

 values_map 
is the KEY-VALUE variable that holds the IDs of the existing account and contact

Response Format

  • The response returned is of the following format:

     {
     "Contacts":"<contact_id>",
     "Deals":"<deal_id>",
     "Accounts":"<account_id>"
     }
  • The following is a sample response returned when a lead is converted into a contact, deal and account:

     {
     "Contacts":"2303XXXXXXXXXXXXXXX",
     "Deals":"2303XXXXXXXXXXXXXXX",
     "Accounts":"2303XXXXXXXXXXXXXXX"
     }
  • The success response returned when the values for the deal is not provided is of the following format:

     {
     "Contacts":"2303XXXXXXXXXXXXXXX",
     "Deals":null
     "Accounts":"2303XXXXXXXXXXXXXXX"
     }
  • The failure response returned for incorrect or non-existent lead ID is of the following format

     {
     "code":"INVALID_DATA",
     "details":{},
     "message":"the related id given seems to be invalid",
     "status":"error"
     }
  • The failure response returned for providing a lead ID that has been already converted is of the following format

     {
     "code":"ID_ALREADY_CONVERTED",
     "details":{},
     "message":"id already converted",
     "status":"error"
     }

Related Links

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocreator.com