Creating A Record In Zoho CRM

 Create a record in CRM Module

You can use Zoho Creator Form to collect information and populate it in Zoho CRM using create() Deluge task.


<CRM Response> = zoho.crm.create(<CRM Module Name>, <Field values as map value>, <optional duplicateCheck as Integer>);

<CRM Response> is the map variable returned by CRM as response.
<CRM Module Name>is the name of the CRM module where the record will be added. For example, "Leads" refers to the Leads module.
<Field values> is the map variable that holds the key,value pairs. The map key is the label name as specified in the CRM module and the map value is the field value as submitted in the ZC form. For example, "Company" : input.Company_Name . Here, "Company" is the label name as specified in the crm module and input.Company_Name refers to the value specified in the Company_Name field in the Zoho Creator form.
<duplicateCheck> Set value as "1" to check the duplicate records and throw an error response or "2" check the duplicate records, if exists, update the same. If the value is not specified, duplicate check will not be performed. Refer here for more details about duplicate check.


For example, the steps to create a lead in CRM from Creator form is described below:

1. Create a Lead Form in Zoho Creator with the following fields

  • Company Name (field type - Single Line)
  • Name (field type - Single Line)
  • Telephone (field type - Single Line)
  • Email Address (field type - Email)

2. Go to the On Add -> On Success section of the above Form, navigate to Free flow script builder and write the script as given below.

//create the CRM vs Creator fields map to push data to the CRM module.

myFieldMap = map();

//add values to the map. CRM fields first and then Creator fields ( without the quotes ). Creator field’s deluge name is used here. 

myFieldMap = map();

myFieldMap.put(“Company”, Company_Name);
myFieldMap.put(“Last Name”, Name);
myFieldMap.put(“Phone”, Telephone);
myFieldMap.put(“Email”, Email_Address);
//function to push data to CRM
response = zoho.crm.create(“Leads”, myFieldMap);

Function explanation:

  • zoho.crm.create() is the function that tells Zoho Creator system to add new record in CRM.
  • CRM Module Name and the Fields map (refer section 2.1) are passed to the function to make sure the right record is added to the right module.
  • response stores the result of the action (success or failure with the record ID of the CRM module).

3. Click on Save Script.

4. Submit data on your Creator Form and check the lead in CRM. 

Note : This example captures only 4 basic fields from CRM Leads module. You can use other fields in the same method too.

 Response Format

"message":"Record(s) added successfully","Created Time":"2011-06-14 12:28:11","Modified By":"ZohoTest","Id":"1584000000028003",
"Modified Time":"2011-06-14 12:28:11", "Created By":"ZohoTest"

 Getting ID of the CRM record

Sample code to get the ID of the CRM record created using the zoho.crm.create() task is given below. 

crmResp = zoho.crm.create("Contacts", tenantinfo);
currentid = (crmResp.get("Id")).toLong();


crmResp is the map variable returned by CRM for the zoho.crm.create() task and contains the ID value of the created crm record.

crmResp.get("Id") will return the ID value of the created crm record. Please refer the sample response format here.

To update the record based on the record id:

crmResp = zoho.crm.updateRecord("Contacts", "" + currentid + "", { "Last Name" : "JoJo" });


To fetch the ID value from CRM, for a given last name, you can first use searchrecords() task to get the id value from the returned map variable and then use the updateRecord task.

 Uploading Files From Creator to CRM

A file uploaded in Zoho Creator using the File upload field, can be pushed to Zoho CRM as an attachment in the zoho.crm.create() task.. The key name for referring to attachment is Attachment in both syntax and response.


fetch = Add_Case [ID == xxxxxxxx];
leadinfo = { "Company" : "Test", "First Name" : "Test", "Last Name" : "test", "Email" : "", "Phone" : "1234567",
"Address" : "test", "City" : "test", "State/Province" : "test", "Country" : "test", "Birth Date" : zoho.currentdate.subYear(20),
"Attachment" : fetch.File_upload };
crmResp = zoho.crm.create("Leads", leadinfo);


fetch is the variable which holds the record values of the given ID
Attachment is the key name which refers to the file attachment.
fetch.File_upload refers to the File_upload field value.


{"message":"Record(s)added successfully","Attachment":"File has been attached successfully" ,"Created Time":"2012-06-08 05:45:50","Modified
By":"Test","Id":"231356000000189001","Modified Time":"2012-06-08 05:45:50","Created By":"Test"};

 Using Script Builder

You can define the create() task using Script Builder by following the steps given below:

  1. Drag and drag the Call function to the builder area and select Integration Tasks .
  2. Select the Service as Zoho CRM and the function as create.
  3. Select the required CRM Module to which the record will be added.
  4. The Field values as map will list the map variable that holds the key value pairs, if already defined. Click on New Map link to specify the key, value pairs, as shown in the screen-shot below:
  5. Specify the CRM Response Variable and click Done to add the task to the script builder.
  6. Click Save Script to add the script. The script will be executed when a record is added to the "Create" form. It will add a record to the "Leads" module in Zoho CRM.

  Creating a task with Contact and Account Lookup

taskInfo = {
"Task Owner" : input.Owner_Name,
"SMOWNERID" : input.Owner_ID,
"Subject" : input.Subject,
"Description" : input.Description,
"SEMODULE" : "Accounts",
"SEID" : input.Account_ID,
"CONTACTID" : input.Contact_ID};
crmResp = zoho.crm.create("Tasks", taskInfo);

SMOWNERID is the ID of the Owner
SEMODULE can be Accounts or Leads or Cases
SEID is the ID of the Record given in the SEMODULE
CONTACTID is the ID of the contact record

 Creating a lead in Zoho CRM and adding a note to the Lead

Sample script to create a "Lead" in Zoho CRM and then add a note to that Lead is given below:

= { "Company" : "Test", "First Name" : "Test", "Last Name" : "Rec", "Email" : "", "Phone" : "1234567", "Address" :  "Test", "City" : "Test", "State/Province" : "Test", "Country" : "Test"};
crmResp = zoho.crm.create("Leads", leadinfo);
entityId =  crmResp.get("Id");
notesMap = { "entityId" : entityId, "Note Title" : "Zoho CRM Sample Note", "Note Content" : "This is sample content to test." };
notesResp = zoho.crm.create("Notes", notesMap);

 Related Topics