Choose where you’d like to start

Upsert record

Description

This task is used to update the values of a particular record using its ID in Zoho CRM.

Note: If the ID is not provided, a new record is created with the specified values.

Syntax

<variable> = zoho.crm.upsert(<module>,<values>,<optional_data>,<[connection>]);

where,

ParamsData typeDescription

<variable>

KEY-VALUE

specifies the response message returned by Zoho CRM. It represents the record's creation and modification details against the API names of the respective fields.

<module>

TEXT

specifies the API name of the module in which the record needs to be created or updated.

<values>

KEY-VALUE

specifies the values of the record that needs to be created or updated.

The record id, if being specified, must be specified here.

Note: Refer this page for details about mandatory fields to create a record.

<optional_data>

(Optional)

KEY-VALUE

Represents other options data(like trigger).

This param can be used to selectively allow the execution of scripts(if any) when the record is added/updated.

Applicable key is trigger, and applicable values are workflowapproval, and blueprint

When this param is specified, the mentioned values will get executed. When this param is not specified, only approvals and blueprints will get executed by default. To restrict all the scripts from getting executed, specify empty list as value to the "trigger" key.

<connection>

(Optional)

TEXT

specifies the name of the connection

Note: The <connection> field is not employed in Zoho Creator.

Example 1

The following script creates a new record in the module - Leads.

 record_values = Map();
 record_values.put("Last_Name","Williams");
 record_values.put("Company","Will Tech");
 response = zoho.crm.upsert("Leads",record_values);

where,

response
variable which holds the response returned by Zoho CRM, which represents the modified by, modified time, created by, and created time information of the created record.
"Leads"
is the TEXT that represents the name of the module in which the record needs to be created
record_values
is the KEY-VALUE variable that holds the new values of the record
"Last_Name" 
"Company" 
are the API names of the Zoho CRM fields. They are of TEXT data type

Example 2

The following script updates the record with ID - 2303XXXXXXXXXXXXXXX, in the module - Leads.

 record_values = Map();
 record_values.put("Last_Name","John");
 record_values.put("id",2303XXXXXXXXXXXXXXX);
 response = zoho.crm.upsert("Leads",record_values);

where,

2303XXXXXXXXXXXXXXX
is the NUMBER that represents the ID of the record that needs to be updated. The record ID can be obtained from the response of Get Records task.

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

Response Format

Success Response

  • The success response returned is of the following format

     {
     "Modified_Time":"2018-12-11T12:15:02+05:30",
     "Modified_By":{"name":"John","id":"2303XXXXXXXXXX"},
     "Created_Time":"2018-12-06T19:01:45+05:30",
     "id":"2303XXXXXXXXXX",
     "Created_By":{"name":"John","id":"2303XXXXXXXXXX"}
     }

Failure Response

  • The failure response returned for incorrect or non-existent record ID is of the following format

     {
     "code":"INVALID_DATA",
     "details":{},
     "message":"the related id given seems to be invalid",
     "status":"error"
     }

Related Links

Get Started Now

Execute