Create Record in Zoho CRM
Table of Contents
Overview
This task is used to create a record in the specified module of Zoho CRM.
Syntax
<variable> = zoho.crm.createRecord(<module_name>, <record_details>, <options_map>, <connection>);
where,
Params | Data type | Description |
<variable> | KEY-VALUE | specifies the response returned by Zoho CRM. It represents the creation and modification details of the record against the API names of its respective fields. |
<module_name> | TEXT | specifies the API name of the Zoho CRM module where the record will be added. |
<record_details> | KEY-VALUE | specifies the input map with key as Zoho CRM field's API name and its required corresponding value. For example: {"Last_name": "Williams"} 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 record is added. Applicable key is trigger, and applicable values are workflow, approval, blueprint, and orchestration. When this param is specified, the mentioned values will get executed. When this param is not specified, only approvals, blueprints, and orchestration 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 connection. Note: The field <connection> is not employed in Zoho Creator. |
Example 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 = { "Company" : "Zylker", "Last_Name" : "Williams", "Phone" : "+1 678 XXX XXXX", "Email" : "will@zylker.com", "PO_Box" : "XXXXX", "Country" : "US" };
response = zoho.crm.createRecord("Leads", leadinfo);
where,
leadinfo
"Company" "Last_Name" "Phone" "Email" "PO_Box" "Country"
"Leads"
response
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.
notesMap = { "Parent_Id" :"2303XXXXXXXXXX", "Note_Title" :"Title", "Note_Content" :"Note_Description", "$se_module" : "Leads"};
response = zoho.crm.createRecord("Notes", notesMap);
where,
notesMap
"Parent_Id" "Note_Title" "Note_Content"
"$se_module"
"Leads"
"Notes"
response
Example 3: Create records in a Custom Module
The following script creates a new record in Zoho CRM custome module - Hotels.
custominfo = { "Name" :"John", "Phone" :"+1 678 XXX XXXX", "Email" :"john@zylker.com" };
response = zoho.crm.createRecord("Hotels", custominfo);
where,
custominfo
"Name" "Phone" "Email"
"Hotels"
response
Response 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:
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"
}