Create records in bulk in Zoho CRM
Overview
We have facilitated the creation of multiple records simultaneously in Zoho CRM under the various modules (listed below in the syntax section). The syntax employed for bulk records creation is almost similar to the zoho.crm.create task just that the input format of the request (data map) would contain data for multiple records. This task is based on Zoho CRM Insert Records API.
Use Case Scenario
Let's say that a user would like to create multiple Zoho CRM records (say Leads) simultaneously. This can be effected by supplying the data for record creation inside a list through the zoho.crm.bulkcreate task. More details on how to execute this task are explained below.
Syntax
<variable> = zoho.crm.bulkCreate(<module_name>, <records_value>, <options_map>, <connection>);
where,
Params | Data Type | Description |
<variable> | KEY-VALUE | specifies the response returned by Zoho CRM. It represents the status of the task, the id of the created record along with the values of the fields against its respective API names. |
<module_name> | TEXT | specifies the API name of the CRM module, where the records will be added. |
<records_value> | LIST | specifies the list containing key-value pairs with the key as each field's API name and its corresponding value. For ex: {"Last_name":"Zoho CRM"} Note: Refer this page for details about mandatory fields in each module. |
<options_map> (optional) | KEY-VALUE | Represents other options data(like trigger). This param can be used to selectively allow the execution of scripts(if any) when the records are added. Applicable key is trigger, and applicable values are workflow, approval, and blueprint. When this param is specified, the mentioned values will get executed. When this param is not specified, only approvals and blueprints will get executed by default. To restrict all the scripts from getting executed, specify empty list as value to the "trigger" key. |
<connection> (optional) | TEXT | specifies the name of the Zoho CRM connection required to accomplish the task Note: This field is not employed in Zoho Creator. |
Example 1: Creating a Lead in Zoho CRM
Let’s take a look below at an example of creating two leads using the lead name, company and email details in Zoho CRM from outside it.
//List that contains key value pairs for bulk create
createList = List();
//Data Map for Lead#1
recordMap1 = {"Company":"Zylker", "Last_Name":"Daly", "First_Name":"Paul", "Email":"p.daly@zylker.com"};
//Data Map for Lead#2
recordMap2 = {"Company":"Tycoon", "Last_Name":"Richard", "First_Name":"Brian", "Email":"brian@villa.com"};
//Add both leads' data to a list
createList.add(recordMap1);
createList.add(recordMap2);
leadInfo = zoho.crm.bulkCreate("Leads",createList);
where,
leadInfo
recordMap1
recordMap2
createList
"Company" "Last_Name" "First_Name" "Email"
"Leads"
Note: The following modules follow a similar process of creating records, as explained in the above example:
- Leads
- Potentials
- Products
- Accounts
- Contacts
- Campaigns
- Vendors
- Cases
Response Format
Following is a successful response when records are created in bulk in Zoho CRM:
"code": "SUCCESS",
"details": {
"Modified_Time": "2018-07-11T18:06:04+02:00",
"Modified_By": {
"name": "Rodriguez",
"id": "3171565000000152015"
},
"Created_Time": "2018-07-11T18:06:04+02:00",
"id": "3171565000000600000",
"Created_By": {
"name": "Rodriguez",
"id": "3171565000000152018"
}
},
"message": "record added",
"status": "success"
},
"code": "SUCCESS",
"details": {
"Modified_Time": "2018-07-11T18:06:04+2:00",
"Modified_By": {
"name": "Rodriguez",
"id": "3171565000000152015"
},
"Created_Time": "2018-07-11T18:06:04+02:00",
"id": "3171565000000600001",
"Created_By": {
"name": "Rodriguez",
"id": "3171565000000152018"
}
},
"message": "record added",
"status": "success"
}
Below is the response returned when a record insertion is attempted without a required field. To know more about error codes, click here.
"code": "MANDATORY_NOT_FOUND",
"details": {
"api_name": "Last_Name"
},
"message": "required field not found",
"status": "error"
}