Create Records

Create Records

The create record deluge task is used in integration scripts to add a new record with specified values.

Syntax


values_map = Map(); 
values_map.put("<field_name>","<field_value>");
response_map=zoho.cliq.createRecord("<database_name>",values_map);

where,

  • field_name = The unique name of the field for which the value has to be added
  • field_value = The value to be added for the particular field
  • database_name = Name of the database in which the field will be added 

Example: 

In the following example, let us consider the Zylker IT Administration team which manages the internal queries and support raised by the employees. The employees use the slash command - /raiserequest to notify the team of their query. The /raiserequest command notifies the IT team of the request made while also creating an record for this request in the Database. 


response = Map();
// Check if the request made is in the correct syntax
if(mentions.size() > 0)
{
// Get details of the request assignee from the @mention made
	userName = mentions.get(0).get("first_name") + " " + mentions.get(0).get("last_name");
	if(arguments.containsIgnoreCase(userName))
	{
		request = arguments.replaceAll(userName,"");
		info request;
		assignee = mentions.get(0).get("id");
		values_map = Map();
		values_map.put("userid",user.get("id"));
		values_map.put("status","Open");
		values_map.put("request",request);
		values_map.put("completed","FALSE");
		values_map.put("requestedby",user.get("first_name"));
		values_map.put("assignedto",userName);
		response_map = zoho.cliq.createRecord("zylkerrequestmanagement",values_map);
		info response_map;
		record_id = response_map.get("object").get("id");
// Frame the command response and post message to the bot using the zoho.cliq.postToBot deluge task and post message to the user as well with the requestID
		responseToUser = {"text":"Thanks! Your request has been raised. Please note the request ID. \n Request ID : " + record_id,"bot":{"name":"ITS Bot","image":"https://assets.lateral.io/newsbot-bot.png"}};
		zoho.cliq.postToChat(chat.get("id"),responseToUser);
		response = {"text":"Hi, a new request has been raised by " + user.get("first_name") + " (" + user.get("email") + ")\n These are the request details: \n Request : " + request,"card":{"theme":"modern-inline","title":"New request assigned to you!"},"buttons":{{"label":"Mark as Complete","key":"" + record_id,"action":{"type":"invoke.function","data":{"name":"updaterecord","owner":"scott.fisher@zylker.com"}},"type":"+"}},"userids":assignee};
		zoho.cliq.postToBot("itsbotm",response);
	}
}
else
{
	response = {"text":"Please describe your request and @mention a user to assign this request! \n ```Sample Syntax: /raiserequest *Your request or incident* @username``` ","bot":{"name":"ITS Bot","image":"https://assets.lateral.io/newsbot-bot.png"}};
	zoho.cliq.postToChat(chat.get("id"),response);
}
return Map();

 

User raises a request  and assigns it to a member of the ITS team using the /raiserequest command. The command input is of the format /raiserequest [arguments]@usermention

raise request slash command

The command is executed to create a record in the Zylker Request Management Database with the request details and if the record creation is successful, a response message is posted to the requester with the request ID and the ITS Bot also notifies the assignee about the request assigned to them. 

raise request response

The ITS Bot notifying the assignee about the request assigned to them.

Notification to assignee

Details of the request raised

Share this post : FacebookTwitter

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

Write to us: support@zohocliq.com