Choose where you’d like to start

Create Record

Note: This task is applicable to all services except Zoho Creator

Overview

This task is used to add a new record with the specified values into a Zoho Cliq database.

This task is based on Zoho Cliq API - Add a record.

Syntax

<variable> = zoho.cliq.createRecord(<database_name>, <data_map>, <connection>);
ParamsData typeDescription

<variable>

KEY-VALUE

specifies the variable which will hold the response returned by Zoho Cliq.

<database_name>

TEXT

specifies the unique name of the database into which the new record will be added.

<data_map>

KEY-VALUE

specifies the content of the new record, each key representing a unique column name from the database and value representing its corresponding data to be added

<connection>

TEXT

specifies the link name of the Zoho Cliq connection

Note:

  • In view of stopping new authtoken generation, a Zoho OAuth connection with appropriate scopes is mandatory for new integration tasks (created after the deadline specified in the post) to work as expected. Existing integration tasks will continue to work with or without the connections parameter unless the authtoken is manually deleted from accounts.
  • Add relevant scopes as mentioned in Zoho Cliq API - Add a record
  • Refer to this post for the list of Zoho services that support the connections page.
  • Learn more about connections

Example 1: Creating a record with static values

The following script adds a new record with the specified values into the Zoho Cliq database - availabilitydatabase.

 values_map=Map();
 values_map.put("name","John");
 values_map.put("empid","1");
 values_map.put("availability","true");
 
 response_map = zoho.cliq.createRecord("availabilitydatabase", values_map, "cliq_connection");

where,

response_map
is the KEY-VALUE returned by Zoho Cliq. It represents the status, URL, data, and ID of the created record
"availabilitydatabase"
is the TEXT that represents the unique name of the database into which the record needs to be added
values_map
is the KEY-VALUE variable that holds the values of the new record
"cliq_connection"
is the TEXT that represents the name of the connection

Example 2: Creating a record with dynamic values

Write the below script in the message handler of your Bot configuration to make it add a new record into the Zoho Cliq database - availabilitydatabase. The values of the fields name and empid are Shawn and 2 respectively. The value of the availability field is adjusted based on the user's response. If the user sends YES to the Bot, the availability field is filled up with true. Otherwise, it is filled up with the default value false.

 response=Map();
 
 values_map=Map();
 values_map.put("name","Shawn");
 values_map.put("empid","2");
 dynamic_value=false;
 
 if(message.equalsIgnoreCase("YES")){
 dynamic_value=true;
 }
 
 values_map.put("availability",dynamic_value);
 text = zoho.cliq.createRecord("availabilitydatabase", values_map, "cliq_connection");
 response.put("text",text);
 return response;

where,

values_map
is the KEY-VALUE variable that holds the values of the new record
message
is the object of TEXT data type that holds the most recent message sent in the Bot
dynamic_value
is the BOOLEAN variable that holds the value of the availability field
"availabilitydatabase"
is the TEXT that represents the unique name of the database into which the record needs to be added
text
is the TEXT variable that holds the response message to be sent by the Bot
"cliq_connection"
is the TEXT that represents the name of the connection

The following is the response of the above script when the user sends YES.

Sample Response

Success Response

  • The success response returned is of the following format

     {
     "status":"SUCCESS",
     "url":"/api/v2/storages/availabilitydatabase/records",
     "object":{"empid":"1","name":"John","availability":true,"id":"1775XXXX0002XXXX009"}
     }

To fetch the ID of the newly created record, execute the following snippet:

<variable> = <response_variable>.get("object").get("id");

Failure Response

  • The failure response returned for an incorrect database name is of the following format

     {
     "status":"FAILURE",
     "message":"Uh-oh! Looks like availablitydata does not exist.",
     "code":"platform_storage_database_not_found"
     }
  • The failure response returned for an incorrect or non-existent field name is of the following format

     {
     "status":"FAILURE",  "message":"The designation column does not exist.",  "code":"platform_storage_column_not_exists"  
     }
  • The failure response for a missing mandatory field is of the following format

     {
     "status":"FAILURE",
     "message":"You have to specify a value for the mandatory column empid",
     "code":"platform_storage_required_field_value_missing"
     }
  • The failure response for a data type mismatch is of the following format

     {
     "status":"FAILURE",
     "message":"Invalid value given for field availability value yes.",
     "code":"platform_storage_fields_invalid_value"
     }
  • The failure response for a duplicate value in unique column is of the following format

     {
     "status":"FAILURE",
     "message":"Looks like this record is a duplicate entry and hence cannot be added!",
     "code":"platform_storage_unique_key_constraint_violated"
     }

Related Tasks

Get Started Now

Execute