Choose where you’d like to start

Create Record in Zoho CRM

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,

ParamsData typeDescription

<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 workflowapprovalblueprint, 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
is the KEY-VALUE variable that holds the values of the record that needs to be created
"Company" 
"Last_Name" 
"Phone" 
"Email" 
"PO_Box" 
"Country"
are the API names of Zoho CRM fields. They are of TEXT data type.
"Leads"
is the TEXT that represents the API name of the Zoho CRM module where the record will be created
response
is the KEY-VALUE response returned by Zoho CRM. It represents the creation and modification details 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.

 notesMap = { "Parent_Id" :"2303XXXXXXXXXX", "Note_Title" :"Title",
 "Note_Content" :"Note_Description", "$se_module" : "Leads"};
 
 response = zoho.crm.createRecord("Notes", notesMap);

where,

notesMap
is the KEY-VALUE variable that holds the input values.
"Parent_Id" 
"Note_Title" 
"Note_Content"
are API names of Zoho CRM fields. They are of TEXT data-type.
"$se_module"
is the API name of the Zoho CRM module to which the note has to be associated.
"Leads"
is the TEXT that represents the module to which the note has to be added
"Notes"
is the TEXT that represents the Zoho CRM module where the record needs to be created
response
is the KEY-VALUE response returned by Zoho CRM. It represents the creation and modification details of the record created against the API names of its respective fields.

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
is the KEY-VALUE variable that holds the input values of the record.
"Name" 
"Phone" 
"Email"
are API names of Zoho CRM fields. They are of TEXT data-type.
"Hotels"
is the TEXT that represents the API name of a sample Zoho CRM Custom Module.
response
is the KEY-VALUE response returned by Zoho CRM. It represents the creation and modification details against the API name of its respective fields.

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:

<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"
    }

Related Links

Get Started Now

Execute