Create Records in Zoho CRM

Create Records in Zoho CRM

Overview

Zoho Creator and Zoho CRM have been integrated for efficient usability purposes. We have developed integration tasks in Zoho Creator to perform automatic actions in Zoho CRM, which would otherwise require manual execution. Lets take the example of creating records. You can add a record in Zoho Creator form(by submitting the form) and have it simultaneously added in Zoho CRM without re-entering data for the second time in CRM. This can be achieved by using zoho.crm.create() task in Zoho Creator.

Use Case Scenario

Let's say we have a Zoho Creator sign-up form which is submitted by users to initiate their interest/probe for a particular product. To create a Lead simultaneously in our Zoho CRM’s "Leads" module, you can execute zoho.crm.create() task in the "On Success" form actions block of the Creator form. This will create a record in Zoho CRM with relevant details whenever the form is submitted. Further details on how to execute this task are explained below.

Syntax

<variable>=zoho.crm.create(<module_name>,{<data_map>},{<optional_data_map>},<connections>);

where,

Params Description

<variable> 

is the response returned as MAP by Zoho CRM.

<module_name> 

is the API name of the CRM module, of STRING datatype, where the record will be added. For example, "Leads" refers to the Leads module. Following is the list of supported modules.

Leads

Potentials

Products

Contacts

Campaigns

Vendors

Accounts

Cases

Quotes

Sales_Orders

Purchase_Orders

Invoices

<data_map>

Input map with key as each field's API name and its corresponding value. For ex: {"Last_name":"Zoho CRM"}

<optional_data_map>

     (optional)

Represents all other data in a map other than input MAP.

<connections> 

Displays the connectors associated with the function. Datatype is STRING.

Example 1: Creating a Lead in Zoho CRM

Let’s take an example of creating a Lead in Zoho CRM by submitting a form in Zoho Creator. Assume we have a Creator form, containing fields:

  • Name (Single Line field type)
  • Company Name (Single Line field type)
  • Phone (Number field type)
  • Email Address (Email field type)
  • PO Box (Number field type)
  • Country (Single Line field type)

The form is used to record details of a potential customer who is interested in buying a product. To create this record simultaneously in Zoho CRM LEAD module, add the following script in the On Add -> On Success block of the form.

leadinfo = {"Company":input.Company_Name,"Last_Name":input.Last_Name,"Phone":input.Phone,"Email":input.Email_Address,"PO_Box":input.PO_Box,"Country":input.Country};
 
response = zoho.crm.create("Leads",leadinfo);

where,

leadinfo
is a map variable that holds the key value pairs.
"Company" 
"Last_Name" 
"Phone" 
"Email" 
"PO_Box" 
"Country"
are API names of Zoho CRM fields. They are of string data-type. 
input.Company_Name 
input.Name 
input.Telephone 
input.Email_Address 
input.PO_Box 
input.Country
are Zoho Creator field inputs.
"Leads"
is the CRM module, of string type, where the record will be created.
response
is response returned as map by Zoho CRM. Check sample response here.

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: Creating a Quote with Account Name, Products list and Subject

Let’s take an example of creating a Quote (containing Account Name, Products list and Subject) in Zoho CRM, by submitting a form in Zoho Creator. Assume we have a Zoho Creator form with fields:

  • CRM Account (Zoho CRM Accounts field type)
  • Subject (Single Line field type)
  • Product Details (Subform field type) containing CRM Product (Zoho CRM Products field type) and Quantity (Number field type) fields.

While submitting the form, to create the quote simultaneously in Zoho CRM Quotes module, add the following script in On Add > On Success block of the Creator Form and click on Save.

quoteDetails=Map(); 
quoteDetails.put("Subject",input.Subject_field); 
quoteDetails.put("Account_Name", {"id" : input.CRM_ACCOUNT_ID});productsList=List:Map(); 
for eachproductininput.Product_Details 
{ 
      productDetails=Map(); 
      productDetails.put("product", {"id" : product.CRM_PRODUCT_ID);
      productDetails.put("quantity",product.Quantity); 
      productsList.add(productDetails); 
} 
quoteDetails.put("Product_Details",productsList);
response=zoho.crm.create("Quotes",quoteDetails);

where,

quoteDetails 
productDetails
are map variables that hold the key value pairs.
"Subject" 
"Account_Name" 
"product" 
"quantity" 
"Product_Details"
are API names of Zoho CRM fields. They are of string data-type.
input.Subject_field 
input.CRM_ACCOUNT_ID 
are Zoho Creator field inputs.
input.Product_Details
is Subform field input.
product
stands for each subform entry or record.
product.CRM_Product_ID 
product.Quantity
are unique Subform field inputs for each Subform entry or record.
productsList
is a list variable containing map values of subform field inputs.
"Quotes"
is the CRM module, of string type, where the record will be created.
response
is response returned as map by Zoho CRM. Check sample response here.

Note: The following modules follow a similar process of creating records, as explained in the above example:

  • Quotes
  • Sales Orders
  • Purchase Orders
  • Invoices

Example 3: Create a Task in CRM with Contact and Account lookup

Let's assume we have a Zoho Creator Form with the following fields:

  • Owner Name (Single Line field type)
  • Owner ID (Number field type)
  • Subject (Single Line field type)
  • Description (Multi Line field type)
  • CRM Account (Zoho CRM Accounts field type)
  • CRM Contact (Zoho CRM Contacts field type)

To create a Task in CRM, add the following script in the On Add > On Success block of the form:

taskInfo={"Owner":{"id":input.Owner_Name);"Subject":input.Subject,"Description":input.Description,"$se_module":"Accounts","What_Id":input.CRM_Account_ID,"Who_Id":input.CRM_Contact_ID};
response=zoho.crm.create("Tasks",taskInfo);

where,

taskinfo
is a map variable that holds the key value pairs.
"Owner" 
"Subject" 
"Description" 
"Who_Id" 
"What_Id"
are API names of Zoho CRM fields. They are of string data-type. 
"$se_module"
API name of the module in Zoho CRM to which the activity has to be associated.
input.Owner_Name 
input.Subject 
input.Description 
input.CRM_Account_ID 
input.CRM_Contact_ID
are Zoho Creator field inputs.
"Accounts"
stands for the module, of string type, to which the task will be attached. In this
case it is "Accounts". 
"Tasks"
is the CRM module, of string type, where the record will be created.
response
is response returned as map by Zoho CRM. Check sample response here.

Example 4: Adding notes to a Lead

Let's say we have a Creator form with the following fields:

  • CRM Lead (Zoho CRM Leads field type)
  • Note Title (Single Line field type)
  • Note Description (Multi Line field type)

Add the following script in the On Add > On Success block of the form to attach Notes to the specified lead:

notesMap={"Parent_Id":input.Zoho_Lead_ID, "Note_Title":input.Note_Title,"Note_Content":input.Note_Description,"$se_module": "Leads"};
 
response=zoho.crm.create("Notes",notesMap);

where,

notesMap
is a map variable that holds the key value pairs.
"Parent_Id" 
"Note_Title" 
"Note_Content"
are API names of Zoho CRM fields. They are of string data-type. 
"$se_module"
API name of the module in Zoho CRM to which the activity has to be associated.
input.Zoho_Lead_ID 
input.Note_title 
input.Note_Description
are Zoho Creator field inputs.
"Leads"
module to which note has to be added. 
"Notes"
is the CRM module, of string type, where the record will be created.
response
is response returned as map by Zoho CRM. Check sample response here.

Example 5: Create an Event

Let's assume we have a Zoho Creator Form with the following fields:

  • Subject (Single Line field type)
  • Event StartTime (Date-Time field type)
  • Event EndTime (Date-Time field type)

To create a record in the Events module with the Form input values, add the following script in On Add > On Success section of the form:

eventinfo={"Event_Title":input.Subject,"Start_DateTime":input.Event_StartTime.toString("yyyy-MM-dd'T'HH:mm:ss'+05:30'","IST"),"End DateTime":input.Event_EndTime.toString("yyyy-MM-dd'T'HH:mm:ss'+05:30'","IST")};
 
response=zoho.crm.create("Events",eventinfo);

where,

eventinfo
is a map variable that holds key value pairs.
"Event_Title" 
"Start_DateTime" 
"End_DateTime"
are Zoho CRM field labels of string type. 
input.Subject 
input.Event_StartTime 
input.Event_EndTime
are Zoho Creator field inputs
"Events"
is Zoho CRM module of string type. 
response
is response returned as map by Zoho CRM. Check sample response here.

Note: The date-time values selected in Zoho Creator are rendered the same in Zoho CRM irrespective of their configured date-time formats.

Example 6: Create records in a Custom Module

Assume we have a Zoho Creator Form and a Custom Module in Zoho CRM, both consisting of the following fields:

  • Name (Single Line field type)
  • Phone(Number field type)
  • Email (Email field type)

To create a record in a Custom Module with the Form input values, add the following script in On Add > On Success section of the form:

custominfo={"Name":input.Name,"Phone":input.Phone,"Email":input.Email };
 
response=zoho.crm.create("Hotels",custominfo);

where,

custominfo
is a map variable that holds the key value pairs.
"Name" 
"Phone" 
"Email"
are Api names of Zoho CRM fields. They are of string data-type. 
input.Name 
input.Phone 
input.Email
are Zoho Creator field inputs
"Hotels"
is the Api name of a sample Zoho CRM Custom Module, of string type.
response
is response returned as map by Zoho CRM. Check sample response here.

Response Format

The response returned is of the following format:

{  
   "Modified_Time":"2018-03-26T14:33:01+05:30",
   "Modified_By":{  
      "name":"Ben",
      "id":"2938383000000132011"
   },
   "Created_Time":"2018-03-26T14:33:01+05:30",
   "id":"2938383000000389001",
   "Created_By":{  
      "name":"Ben",
      "id":"2938383000000132011"
   }
}

If record creation fails due to any reason, a failure response of the following format is returned. To know more about error codes, click here.

{  
   "code":"MANDATORY_NOT_FOUND",
   "details":{  
      "api_name":"Last_Name"
   },
   "message":"required field not found",
   "status":"error"
}

Limitation

CRM Tasks can be executed only in accounts which are under Flexible and Unlimited Plans. Accounts under Free Plan, kindly upgrade to use CRM tasks. For more details scroll down to Integration and Web Data on the pricing page.

Script Builder

You can also make use of Script builder to define the zoho.crm.create() task. Navigate to your application’s Workflow and drag and drop the Call Function under Deluge Tasks > Miscellaneous. Select Integration tasks and fill out necessary information.

Related Links

  • To fetch the string value to which the specified key is mapped, use get()
  • To get values from fetched records, use getJSON()

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohocreator.com