Creator Help

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.

Syntax

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

where,
<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.

Example

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

  1. Create a form in Zoho Creator with the required fields, as shown in the screen-shot below:
  2. Select More Actions -> Script on Add -> Actions on Success from the Form header. This will display the Script Editor in the Script tab with the Form Actions -> On add -> On Success block selected in the left-side tree.
  3. In the editor area, write the Deluge script to populate the form data in CRM, in the format given below.
  4. Click Save Script to save the script. The sample code is given below for reference. Here, leadinfo is the map variable that holds the key, value pairs and "Leads" is the CRM module name.

leadinfo = {
"Task Owner" : input.Owner_Name,
"SMOWNERID" : input.Owner_ID,
"Last Name" : input.Name,
"Company" : input.Company_Name,
"First Name" : input.First_Name,
"Lead Source" : "Advertisement",
"Campaign Source" : "Website Contact us Form",
"Description" : input.Comments,
"Email" : input.Email_Id
};
crmResp = zoho.crm.create("Leads", leadinfo);

The above is a wrapper for insertRecord API defined in https://zohocrmapi.wiki.zoho.com/insertRecords-Method.html

Code Explanation

leadinfo is the map variable that holds the key,value pairs.
Leads is the module name in Zoho CRM
crmResp is the map variable returned by CRM as response.

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

On submit, the record is added to the Zoho CRM Leads module as shown in the screen-shot below.

Sample Application

Please refer the Zoho Creator sample application CRM-Creator-Invoice Integration

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.

Example

fetch = Add_Case [ID == xxxxxxxx];
leadinfo = { "Company" : "Test", "First Name" : "Test", "Last Name" : "test", "Email" : "test@zoho.com", "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);

where,

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.

Response

{"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);

where,
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

Related Topics

https://kbase.creator.zoho.com/category/crm

http://www.zoho.com/crm/help/api/insertrecords.html

Top