Create Record in Zoho CRM V8
Table of Contents
Overview
This task is used to create a new record in the specified module of Zoho CRM.
Syntax
<variable> = zoho.crm.v8.createRecord(<module_name>, <record_details>, <options_map>, <connection>);
where,
| Parameter | Data type | Description |
| <variable> | KEY-VALUE | Holds the response returned by Zoho CRM. Here it specifies the creation and modification details on successful record creation. |
| <module_name> | TEXT | Specifies the API name of the Zoho CRM module where the record will be added. |
| <record_details> | KEY-VALUE | Represents the input collection (key–value pairs) where each key is a Zoho CRM field's API name mapped to the corresponding value to be inserted into that field. For example: {"Last_Name": "Williams"}, here Last_Name represents the field API name (key), and "Williams" represents the value inserted into that field. Note: Each module in Zoho CRM contains mandatory fields that are required to create a record. Refer to this page for the list of mandatory fields in each module. |
<options_map> (optional) | KEY-VALUE | An optional parameter, used to allow selective CRM automations on successful record creation. Applicable key is trigger, and applicable values are workflow, approval, blueprint, and orchestration. When the options_map parameter is specified in the function call, the mentioned When this parameter is excluded, approvals, blueprints, and orchestration automations will get executed by default. To restrict all the CRM automations from getting executed, set the value of the “trigger” key to an empty list. |
| <connection> | TEXT | Represents the link name of the connection which is connected to your Zoho CRM account. Note:
|
Examples
1. Creating a Lead in Zoho CRM
The following script creates a new record with the specified values in the Zoho CRM module - Leads.
leadinfo = Collection( "Company" : "Zylker", "Last_Name" : "Williams", "Phone" : "+1 678 XXX XXXX", "Email" : "will@zylker.com", "PO_Box" : "XXXXX", "Country" : "US" );
response = zoho.crm.v8.createRecord("Leads", leadinfo);
where,
leadinfo"Company" "Last_Name" "Phone" "Email" "PO_Box" "Country"
"Leads"responsedetails of the record against the API names of its respective fields.
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
Example 2: Adding notes to a Lead
The following script creates a new record in the Notes submodule of the lead with ID - 2303XXXXXXXXXX.
notes_data = Collection( "Parent_Id" : "2303XXXXXXXXXX", "Note_Title" : "Title", "Note_Content" : "Note_Description", "$se_module" : "Leads" );
response = zoho.crm.v8.createRecord("Notes", notes_data);
where,
notes_data"Parent_Id" "Note_Title" "Note_Content"
"$se_module""Leads""Notes"responseExample 3: Create records in a Custom Module
The following script creates a new record in Zoho CRM custom module - Hotels.
custominfo = Collection( "Name" : "John", "Phone" : "+1 678 XXX XXXX", "Email" : "john@zylker.com" );
response = zoho.crm.v8.createRecord("Hotels", custominfo);
where,
custominfo"Name" "Phone" "Email"
"Hotels"responseResponse Format
Success Response
The response returned is of the following format:
{
"Modified_Time":"2018-03-26T14:33:01+05:30",
"Modified_By":{
"name":"Ben",
"id":"2303XXXXXXXXXX"
},
"Created_Time":"2018-03-26T14:33:01+05:30",
"id":"2303XXXXXXXXXX",
"Created_By":{
"name":"Ben",
"id":"2303XXXXXXXXXX"
}
}
- To get the ID of the newly created record, execute the following script:
<variable> = <response_variable>.get("id").toLong();
Failure Response
The failure response returned is of the following format. To know more about error codes, click here.
{
"code":"MANDATORY_NOT_FOUND",
"details":{
"api_name":"Last_Name"
},
"message":"required field not found",
"status":"error"
}