Update Records in Zoho CRM

Update Records in Zoho CRM

Overview

Automate the process of updating records in Zoho CRM, using zoho.crm.updateRecord() task in Zoho Creator.

Syntax

<response> =zoho.crm.updateRecord(<module_name>, <record_ID>, <data_map>, {<optional_data_map>});

where,

Params DescriptionData type

<response> 

is the response returned by Zoho CRM.

MAP

<module_Name> 

is the API name of the CRM module where the records will be updated. 

Following is the list of supported modules.

Leads

Potentials

Products

Contacts

Campaigns

Vendors

Accounts

Cases

Quotes

Sales_Orders

Purchase_Orders

Invoices

Note: Refer this for the instructions to get API names of the CRM modules and fields.

STRING

<record_Id>

is the id of the record that needs to be updated.

NUMBER

<data_map>

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

MAP

<optional_data_map>

         (optional) 

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

MAP


Example 1: Update a Lead record by specifying it's id

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

  • Lead(Zoho CRM Leads field type)
  • Company Name (Zoho CRM Leads field type)
  • Name (Single Line field type)
  • Telephone (Number field type)
  • Email Address (Email field type)

Add the following script in On Add > On Success to update details of the specified Lead id.

leadinfo = {"Company":input.Company_Name, "Last_Name":input.Name, "Phone":input.Telephone, 
"Email":input.Email_Address}; 

response = zoho.crm.updateRecord("Leads",input.Lead_ID,leadinfo);

where,

leadinfo
contains key values pairs, where the keys are API names of Zoho CRM fields and values are updated field inputs.
response
is the response returned as map by Zoho CRM. The fetched records will be contained in the response. Check sample response here.
"Leads"
is the label name of Zoho CRM Leads Module, of string datatype, where the records will be updated.
input.Lead_ID
refers to the Form field(Lead) input.

Example 2: Update a Quote with Product details by specifying the Quote ID

Let's assume we have a Zoho Creator Form used to store Quotes and its Products details. The Form consists of the following fields:

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

Add the following script in On Add > On Success section of your Form to update an existing Quotes record:

quoteDetails = map(); 
quoteDetails.put("Subject", input.Subject); 
quoteDetails.put("Account_Name", {"id":input.CRM_ACCOUNT_ID);productsList = List:Map(); 
 
for each product in input.Product_Details 
{ 
Product_Details = map(); 
Product_Details.put("product", {"id":product.CRM_PRODUCT_ID);Product_Details.put("quantity", product.Quantity); 
productsList.add(productDetails); 
} 
quoteDetails.put("Product_Details", productsList); 

response = zoho.crm.updateRecord("Quotes", QuotesID, quoteDetails);

where,

response
is the response returned as map by Zoho CRM. The fetched records will be contained in the response. Check sample response here.
"Subject" 
"Account_Name" 
"product" 
"quantity" 
"Product_Details"
are API names of Zoho CRM fields. They are of string data-type.
input.Subject 
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 datatype, where the record will be updated.
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-26T15:17:39+05:30",
   "Modified_By":{  
      "name":"Ben",
      "id":"2938383000000132011"
   },
   "Created_Time":"2018-03-26T14:39:28+05:30",
   "id":"2938383000000392001",
   "Created_By":{  
      "name":"Ben",
      "id":"2938383000000132011"
   }
}

Related Links

  • To fetch the string value to which the specified key is mapped, use get()
  • To get values from fetched records, use getJSON()
  • To convert the json string to list format, use toJSONList().

Share this post : FacebookTwitter

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

Write to us: support@zohocreator.com