Create Records in Zoho CRM
Table of Contents
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.v1.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.v1.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.v1.create(<module_name>,<field_values>,[<duplicate_check>]);
where,
| Params | Description | ||||||||||||
<variable> | is the response returned as MAP by Zoho CRM. | ||||||||||||
<module_name> | is the 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.
| ||||||||||||
<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. | ||||||||||||
<duplicate_check> (optional) | is ofNUMBERdatatype. The following table represents the duplicate check values and it's description.
|
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 Success workflow section 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.v1.create("Leads",leadinfo);
where,
leadinfo"Company""Last Name""Phone""Email""PO Box""Country"
input.Company_Nameinput.Nameinput.Telephoneinput.Email_Addressinput.PO_Boxinput.Country
"Leads"responseNote: 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 Success workflow section of the Creator Form and click on Save.
quoteDetails=Map();quoteDetails.put("Subject",input.Subject_field);quoteDetails.put("ACCOUNTID",input.CRM_ACCOUNT_ID);productsList=List:Map();for each product in input.Product_Details{productDetails=Map();productDetails.put("Product Id",product.CRM_PRODUCT_ID);productDetails.put("Quantity",product.Quantity);productsList.add(productDetails);}quoteDetails.put("Products",productsList);
response=zoho.crm.v1.create("Quotes",quoteDetails);
where,
quoteDetailsproductDetails
"Subject""ACCOUNTID""Product Id""Quantity""Products"
input.Subject_fieldinput.CRM_ACCOUNT_IDinput.Email_Address
input.Product_Details
productproduct.CRM_Product_IDproduct.Quantity
productsList"Quotes"responseNote: The following modules follow a similar process of creating records, as explained in the above example:
- Quotes
- Sales Orders
- Purchase Orders
- Invoices
Example 3: Upload an attachment to Zoho CRM
Let's say we have a Zoho Creator form to store Leads which contains, among other field types, a file-upload field type. The label name for attachment in CRM is Attachment in both syntax and response. To upload an attachment in CRM, the following script can be added to On Success workflow section.
leadinfo={"Company":input.Company,"Last Name":input.Name,"Email":input.Email,"Attachment":input.File_upload};
response=zoho.crm.v1.create("Leads",leadinfo);
where,
leadinfo"Company""Last Name""Email""Attachment"
input.Companyinput.Nameinput.Emailinput.File_upload
"Leads"will be created.
responseExample 4: 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 Success workflow section of the form:
taskInfo={"Task Owner":input.Owner_Name,"Subject":input.Subject,"Description":input.Description,"SEMODULE":"Accounts","SEID":input.CRM_Account_ID,"CONTACTID":input.CRM_Contact_ID};
response=zoho.crm.v1.create("Tasks",taskInfo);
where,
taskinfo"Task Owner""Subject""Description""SEMODULE""SEID""CONTACTID"
input.Owner_Nameinput.Subjectinput.Descriptioninput.CRM_Account_IDinput.CRM_Contact_ID
"Accounts"case it is "Accounts".
"Tasks"responseExample 5 : 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 Success workflow section of the form to attach Notes to the specified lead:
notesMap={"entityId":input.Zoho_Lead_ID, "Note Title":input.Note_Title,"Note Content":input.Note_Description};
response=zoho.crm.v1.create("Notes",notesMap);
where,
notesMap"entityId""Note Title""Note Content"
input.Zoho_Lead_IDinput.Note_titleinput.Note_Description
"Notes"responseExample 6 : 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 Success workflow section of the form:
eventinfo={"Subject":input.Subject,"Start DateTime":input.Event_StartTime,"End DateTime":input.Event_EndTime };
response=zoho.crm.v1.create("Events",eventinfo);
where,
eventinfo"Subject""Start Date Time""End Date Time"
input.Subjectinput.Event_StartTimeinput.Event_EndTime
"Events"responseNote: The date-time values selected in Zoho Creator are rendered the same in Zoho CRM irrespective of their configured date-time formats.
Example 7 : 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 Success workflow section of the form:
custominfo={"Name":input.Name,"Phone":input.Phone,"Email":input.Email };
response=zoho.crm.v1.create("CustomModule1",custominfo);
where,
custominfo"Name""Phone""Email"
input.Nameinput.Phoneinput.Email
"CustomModule1"of Zoho CRM Custom Module can be used to retrieve the Custom Module label name.
For example - https://crm.zoho.com/crm/CreateEntity.do?module=CustomModule1
responseNote: Custom Modules are by default named as CustomModuleX (where X is a number). Specify the same Custom Module name format in the syntax. The URL of Zoho CRM Custom Module can be used to retrieve the Custom Module label name. For example - https://crm.zoho.com/crm/CreateEntity.do?module=CustomModule1
Response Format
The response returned is of the following 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"
}
To get the ID of the newly created record, execute the following script:
currentid=response.get("Id").toLong();
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.
"message":"No CRM account",
"code":"4102"
}
