Create Record in Zoho CRM V8

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,

ParameterData typeDescription
<variable> KEY-VALUEHolds the response returned by Zoho CRM. Here it specifies the creation and 
modification details on successful record creation.
<module_name>TEXTSpecifies 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 
values will get executed.

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
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.
"Leads"
is the TEXT that represents the API name of the Zoho CRM module where the record will be created.
response
is the variable which holds the data 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.

 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
is the KEY-VALUE variable that holds the input values.
"Parent_Id"
"Note_Title"
"Note_Content"
are API names of Zoho CRM fields.
"$se_module"
is a system parameter key to which a Zoho CRM module will be mapped.
"Leads"
is the API name of the Zoho CRM module to which the note has to be added.
"Notes"
is the Zoho CRM module where the record needs to be created.
response
holds the data 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 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
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 API name of a Zoho CRM Custom Module.
response
holds the data 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"
    }