Update Records in Zoho CRM
Table of Contentsup
Overview
Automate the process of updating records in Zoho CRM, using zoho.crm.updateRecord() task in Zoho Creator.
Syntax
<variable> =zoho.crm.updateRecord(<module_name>, <record_ID>, <data_map>, {<optional_data_map>});
where,
Params | Description | Data type | ||||||||||||
<variable> | 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.
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 its ID
Let's assume we have a Zoho Creator Form with the following fields:
- 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 the On Success workflow to update details of the specified Lead id.
leadinfo = {"Company":input.Company_Name, "Last_Name":input.Name, "Phone":input.Telephone, "Email":input.Email_Address}; resp = zoho.crm.updateRecord("Leads",input.Lead_ID,leadinfo);
where,
leadinfo
resp
"Leads"
input.Lead_ID
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 the On Success workflow 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); resp = zoho.crm.updateRecord("Quotes", QuotesID, quoteDetails);
where,
resp
"Subject" "Account_Name" "product" "quantity" "Product_Details"
input.Subject input.CRM_ACCOUNT_ID
input.Product_Details
product
product.CRM_Product_ID product.Quantity
productsList
"Quotes"
response
Response Format
The response returned is of the following format:
"Modified_Time": <Date/Time in ISO 8601 format>,
"Modified_By": {
"name": <User_Name>,
"id": <user_id>
},
"Created_Time": <Date/Time in ISO 8601 format>,
"id": "id of the record updated",
"Created_By": {
"name": <User_Name>,
"id": <user_id>
}
}
The following is a sample response when a lead is updated in Zoho CRM:
"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().