Updating Records

You can update a record of a module in an Extension or Vertical Solution using the zoho.crm.updateRecord() deluge task.

Syntax

<Response> = zoho.crm.updateRecord(<module String>,<recordID Long>,<dataMap Map>);

where,
<Response> is the task response returned as a Map.

Parameters

NameDatatypeDescriptionMandatory
moduleStringSpecify the API name of the module whose record needs to be updated.Yes
recordIDLongThe unique ID of the record you want to update.Yes
dataMapMapThe map containing the key, value pairs denoting the fields to be updated, and the value with which the field should be updated. The keys to be used here are the API names of the fields. Use the Refer Fields in the Deluge Script Editor to learn these names.Yes

 Example

Update the address fields of a related contact with the address details in the parent Account record.

accountId = account.get("Accounts.ID");
relRecordsResp = zoho.crm.getRelatedRecords("Contacts","Accounts",accountId);
recordResp = zoho.crm.getRecordById("Accounts",accountId);
contact_address = Map();
contact_address.put("Mailing_Street",recordResp.get("Shipping_Street"));
contact_address.put("Mailing_City",recordResp.get("Shipping_City"));
contact_address.put("Mailing_State",recordResp.get("Shipping_State"));
contact_address.put("Mailing_Zip",recordResp.get("Shipping_Code"));
contact_address.put("Mailing_Country",recordResp.get("Shipping_Country"));
contact_address.put("Other_Street",recordResp.get("Billing_Street"));
contact_address.put("Other_City",recordResp.get("Billing_City"));
contact_address.put("Other_State",recordResp.get("Billing_State"));
contact_address.put("Other_Zip",recordResp.get("Billing_Code"));
contact_address.put("Other_Country",recordResp.get("Billing_Country"));
for each ele in relRecordsResp
{
contactId = ele.get("id");
updateResp = zoho.crm.updateRecord("Contacts",contactId,contact_address);
info updateResp;
}

In the line of code, contact_address.put("Mailing_Street",recordResp.get("Shipping_Street"));, Mailing Street is the label of the field in the related record that needs to be updated and (recordResp.get("Shipping_Street") fetches the value of the field in the parent module (account). This value will be used to update the field in the related record (contacts).

 Response Format

Shown below is the response generated for the above code:

{"Modified_Time":"2018-10-24T14:50:26+05:30","Modified_By":{"name":"ZohoDemo ","id":"3388926000000166021"},"Created_Time":"2018-10-22T10:29:20+05:30","id":"3388926000000297018","Created_By":{"name":"ZohoTest","id":"3388926000000166021"}}

 Additional Examples

Updating a task with Contact and Account Lookup

Obtain the task ID as user input and update the Contact and Account lookups with existing Contact and Account record details.

taskId = task.get("Tasks.ID");
accMap = Map();
accMap = {"id":3388926000000297008};
contactMap = Map();
contactMap = {"id":3388926000000285001};
taskMap = Map();
taskMap = {"Status":"In Progress","$se_module":"Accounts","What_Id":accMap,"Who_Id":contactMap};
updateResp = zoho.crm.updateRecord("Tasks",taskId,taskMap);
info updateResp;

 Response

Shown below is the response generated for the above code:

{"Modified_Time":"2018-10-24T15:20:46+05:30","Modified_By":{"name":"ZohoDemo","id":"3388926000000166021"},"Created_Time":"2018-10-23T15:47:10+05:30","id":"3388926000000301077","Created_By":{"name":"ZohoTest","id":"3388926000000166021"}}

 Related Links

https://www.zoho.com/crm/help/api/v2/#update-specify-records