Upsert

Upsert

Description

The zoho.crm.upsert task is used to update the values of a particular record using its ID(optional) in Zoho CRM.

Note: If the ID is being specified, it should be included in the map. If the ID is not provided, a new record is created with the specified values. Record IDs can be obtained from the response returned from Get Records task.

Syntax

<response> = zoho.crm.upsert(<module>,<values>,<optional_data>);

where,

ParamsDescriptionData type

<response>

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.

MAP

<module>

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

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

STRING

<values>

specifies the values of the record that needs to be created or updated, in a map format with key as CRM field's API name and its required corresponding value. 

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

MAP

<optional_data>

(Optional)

specifies additional values other than the input values.
Possible Key: trigger
Possible Values: workflow, approval, blueprint

MAP


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
is the KEY-VALUE response returned by Zoho CRM, which represents the modified by, modified time, created by, and created time information of the updated record.
"Leads"
is the TEXT that represents the name of the module where the record needs to be updated
record_values
is the KEY-VALUE variable that holds the new values of the record

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.

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

Share this post : FacebookTwitter

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

Write to us: support@zohocreator.com