Delete Records

Delete Records

The delete record deluge task can be used to delete records satisfying a particular criteria. 

Syntax

query_map = Map(); 
criteria_string="<field_name>==<field_value>"; 
query_map.put("criteria",criteria_string); 
response_map=zoho.cliq.getRecords("<database_name>", query_map); 
record_id = 0;
if(response_map.get("status").equalsIgnoreCase("SUCCESS") && response_map.get("list").size()>0)
{ 
    record_id=response_map.get("list").get(0).get("id"); 
} 
if(record_id > 0)
{ 
    zoho.cliq.deleteRecord("<database_name>", record_id); 
} 

Example

Let us assume that a user who has raised a request with the IT Admin team wants to delete the request. The user can execute the /myrequests command to get the list of requests raised and click on the delete request option. By doing so, the deleterecord function associated with the Delete button is triggered to delete the record permanently.


response = Map();
buttonKey = arguments.get("key");
info buttonKey;
response_map=zoho.cliq.getRecordById("zylkerrequestmanagement", buttonKey); 
if(response_map.get("status").equalsIgnoreCase("SUCCESS"))
{ 
 // zoho.cliq.deleteRecord tasks deletes the record using the record_id. record_id here is stored in the buttonKey variable.deleteRecord = zoho.cliq.deleteRecord("zylkerrequestmanagement",buttonKey); 
 info deleteRecord;
} 
response.put("text","The request has been successfully deleted. :thumbsup:");
return response;

 

A user can execute the /myrequests command to view the list of requests raised and delete any request if necessary. 

Delete a bunch of records using criteria

The delete records deluge task can be used to delete a bunch of records satisfying a particular criteria.

Syntax


query_map=Map();
criteria_string="<field name>==<field value>";
query_map.put("criteria",criteria_string");
response_map=zoho.cliq.getRecords("<database_name>",query_map);
info response_map;
if(response_map.get("status")equalsIgnoreCase("SUCCESS")&&response_map.get("list").size()>0)
{
zoho.cliq.deleteRecords("<database_name>",criteria_string);
}
return Map();

Example

Let us assume that a user has raised a couple of requests with the IT Admin team through an ITS bot and wants to delete the records that are marked as closed. The user can now click on the My Requests from the bot menu action to get the list of requests raised. This displays a Closed Requests button clicking on which presents the user with a list of requests marked as closed. Further clicking on the Delete Requests button will execute the deleteRecord task and delete the records.

​query_map = Map();
criteria_string = "status==Close";
query_map.put("criteria",criteria_string);
response_map = zoho.cliq.getRecords("zylkerrequestmanagement",query_map);
info response_map;
if(response_map.get("status").equalsIgnoreCase("SUCCESS")&&response_map.get("list").size()>0)
{
zoho.cliq.deleteRecords("zylkerrequestmanagement",criteria_string);
}
return Map();

 

Share this post : FacebookTwitter

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

Write to us: support@zohocliq.com