How can I add records to a ZC application using API

How can I add records to a ZC application using API

The application Add Record using API illustrates the usage of the Deluge postURL task to add a new record to another Zoho Creator application. Here we use the Zoho Creator XML RPC API to add a new record. The application comprises of a dummy form "POST URL" with fields "TaskName" and "TaskDescr". When the form is submitted, a new record is added to another Zoho Creator application named "task-management" with form name "Tasks" with the values entered in the dummy form. 

Steps in adding a new record using the XML-RPC API

1. The POST method format to add a new record using the XML-RPC API is given below:

<form method="POST" action="http://creator.zoho.com/api/xml/write/apikey=[APIKEY]&ticket=[Ticket]">
<input type="hidden" name="XMLString" value="XML String in the format as specified in the Request format">
<input type="submit" value="Sumit XML String">
</form>

2. The request parameters (i.e) the application name, form name and the record values to be updated must be specified in the prescribed format:

<ZohoCreator>
<applicationlist>
<application name="applicationName">
<formlist>
<form name="formName">
<add>
<field name="fieldName"><value>fieldValue</value></field>
<field name="fieldName"><value>fieldValue</value></field>
<field name="fieldName"><options><option>Option 1</option><option>Option 2</option>
</field>
</add>
</form>
</formlist>
</application>
</applicationlist>
</ZohoCreator>

3. In this example,

- "task-management" is the name of the application to which a new record is added
- "Tasks" is the form name with field names "Task" and "Description.
- The field value
 input.TaskName refers to the value specified in the TaskName field of the dummy form. 
- The field value 
input.TaskDescr refers to the value specified in the TaskDescr field of the dummy form.

"<ZohoCreator>
<applicationlist>
<application name=\
"task-management\">
<formlist>
<form name=\
"Tasks\">
<add>
<field name=\"Task\"><value>
input.TaskName</value></field>
<field name=\"Description\"><value>
input.TaskDescr</value></field>
</add>
</form>
</formlist>
</application>
</applicationlist>
</ZohoCreator>"

4. The following Deluge Script is added to the On click action of the dummy form to add a new record using the XML-RPC API. The script will be executed on click of the form button. Refer Deluge Script for the code explanation.

form  Post_URL1
{
displayname = "Add Record using API"
store data in zc = false

TaskName
(
type = text
)

TaskDescr
(
type = textarea
)

actions
{
On_Click
(
type = submit
displayname = "On Click"
on click
{
mapvariable = map();
mapvariable.put("XMLString",
"<ZohoCreator>
<applicationlist><application name=\"task-management\">
<formlist>
<form name=\"Tasks\"><add><field name=\"Task\"><value>" + input.TaskName + "</value></field>
<field name=\"Description\"><value>" + input.TaskDescr + "</value></field></add>
</form>
</formlist>
</application></applicationlist>
</ZohoCreator>");
mapvariable.put("zc_ownername", "zc_help");
ResponseMapVariable = postUrl("http://creator.zoho.com/api/xml/write/apikey=1234&ticket=1234",
mapvariable,false);
);
}
)

}
}

Using Script Builder

In the Script builder we have created a map variable with the above Key and Value.



Code Explanation

  • The create map task creates a new map variable named MapVariable
  • The put key task adds the key, value pair to the MapVariable with values as specified by the Zoho Creator API.


  • The post data posts the specified data to the external Zoho Creator application "task-management" with form name "tasks". The request url string to add a record using XML-RPC is 
http://creator.zoho.com/api/xml/write/apikey=1234&ticket=1234". Users need to have an 'API Key' as well as a 'Ticket ID' for accessing the Zoho API.


  • When the above script is executed, the Tasks view in the Task Management application is updated with the new record value.

 

To install the application,

  1. Download the script file (.ds file)
  2. Install the application to your account. Click here to learn how to install using the script file (.ds file)

    • Related Articles

    • How can I add a new record to another Zoho Creator application using the Deluge postURL task?

      Refer the following topic : http://kbase.creator.zoho.com/adding-records/adding-records-to-a-zc-application-using-api
    • Using Gmail API

      Zoho CRM provides a variety of emailing options that users can choose based on their requirements. One such option is the Zoho Mail Add-on. With Zoho Mail Add-on, you can configure your email client within Zoho CRM using either one of the two ...
    • API Limits

      The Zoho Recruit API is available in all editions of Zoho Recruit. To use the API, you'll require the Zoho Recruit Authentication Token from your Recruit account. Please make sure that you have permission to access the API service. If you do not have ...
    • Serverless Functions - Using API Key

      Introduction A severless function within your CRM can be invoked from any third-party application or within the CRM using a webhook. However, generally most of the webhooks do not support OAuth2, save for a few of them. In that case, you can execute ...
    • What are the different ways of deleting records from a Zoho Creator application?

      You can remove old or unwanted records from your database by directly deleting them from the View or by executing Deluge Script or by using Zoho Creator APIs.  Once a record is deleted, you cannot retrieve the data it contained.   Who can delete ...