Bulk Create Records in Zoho CRM

Bulk Create Records in Zoho CRM

Overview

Automate the process of adding records in bulk in Zoho CRM, using zoho.crm.bulkCreate() task in Zoho Creator. 

Syntax

<variable> = zoho.crm.bulkCreate(<module_name>, <data_map_list>, [<optional_data_map>]);

where,

ParamsDescriptionData Type

<variable>

is the response returned as a list of key value pairs containing the status of the task, the ID of the created record along with other relevant details

LIST

<module_name>

is the API name of the CRM module, where the records will be added. Following is the list of supported modules:

Leads

Deals

Products

Contacts

Campaigns

Vendors

Accounts

Cases

Quotes

Sales_Orders

Purchase_Orders

Invoices

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

TEXT

<data_map_list>

is the list containing key value pairs with key as each field's API name and its corresponding value. For ex: {"Last_name":"Zoho CRM"}

LIST

<optional_data_map>

(optional)

contains optional data other than what is provided in a data_map_list

MAP

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.

//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
is a LIST that contains data KEY-VALUE pairs
recordMap1
recordMap2
are KEY-VALUE pairs that contain the data for creating Lead records
createList
is a LIST variable that contains the KEY-VALUE pairs
"Company" 
"Last_Name" 
"First_Name" 
"Email" 
are API names of ZOHO CRM Lead fields of type TEXT
"Leads"
is the name of the CRM module where the record will be created. It is of TEXT type

Note: The following modules follow a similar process of creating records, as explained in the above example:

  • Leads
  • Deals
  • Products
  • Accounts
  • Contacts
  • Campaigns
  • Vendors
  • Cases

Response Format

The response returned is of the following format:

{
"code": "SUCCESS",
"details": {
"Modified_Time": <Date/Time_in_ISO_8601_format>,
"Modified_By": {
"name": <User_Name>,
"id": <user_id>
},
"Created_Time": <Date/Time_in_ISO_8601_format>,
"id": <id-of_the_record_created>,
"Created_By": {
"name": <User_Name>,
"id": <user_id>
}
},
"message": "record added",
"status": "success"
},
{
"code": "SUCCESS",
"details": {
"Modified_Time": <Date/Time_in_ISO_8601_format>,
"Modified_By": {
"name": <User_Name>,
"id": <user_id>
},
"Created_Time": <Date/Time_in_ISO_8601_format>,
"id": <id of the record created>,
"Created_By": {
"name": <User_Name>,
"id": <user_id>
}
},
"message": "record added",
"status": "success"
}

Following is a sample 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 failure response returned when a record insertion is attempted without a required field.

{
"code": "MANDATORY_NOT_FOUND",
"details": {
"api_name": "Last_Name"
},
"message": "required field not found",
"status": "error"
}

Related Links

  • To know more about error codes, click here.
  • To fetch the string value to which the specified key is mapped, use get()
  • To get values from fetched records, use getJSON()

Share this post : FacebookTwitter

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

Write to us: support@zohocreator.com