Create Record
Table of Contents
Overview
This task is used to create a record in Zoho Creator.
Syntax
<variable>= zoho.creator.v1.createRecord(<ownerName>, <appLinkName>, <formLinkName>, <dataMap>, <connectionlinkName>);
where,
Params | Data Type | Description |
<variable> | KEY-VALUE | Variable which will hold the returned response. |
<ownerName> | TEXT | is the name of the owner of the app in which the record will be created. Name of the app owner is present in the url while editing the app: creator.zoho.com/appbuilder/<appOwner> App owner name can also be fetched using the system variable zoho.adminuser |
<appLinkName> | TEXT | is the link name of the application in which the record will be created. Link names of applications, forms, and fields in your account can be viewed here (listed in brackets). Application Link name can also be fetched using the system variable zoho.appname |
<formLinkName> | TEXT | is the link name of the form in which the record will be added. Link names of applications, forms, and fields in your account can be viewed here (listed in brackets). |
<dataMap> | KEY-VALUE | contains field link names and their corresponding values for record creation in Zoho Creator form |
<connectionLinkName> (optional)* | TEXT | is the name of the Zoho Creator connection. *Note
|
Example
Let us consider the below example of creating a record in Zoho Creator. Assume that we have a form with the two fields - Task_Name (Single Line Field Type) and Task_Description (Single Line Field Type). The arguments - Task_Management (Application Link Name), Create_Task (Form Link Name), tony (Owner Name) will be supplied to createRecord() in the following example.
dataMap = {"Task_Name":"Priority Task", "Task_Description":"I need help configuring my new toaster"};
response = zoho.creator.v1.createRecord("tony", "Task_Management", "Create_Task", dataMap);
where,
response
tony
Task_Management
Create_Task
datamap
Sample Response
Success
Following is a successful response received after creating a record:
{
"Task_Description":"I need help configuring my new toaster",
"ID":3605445000000075003,
"Task_Name":"Priority Task"
},
"status":"Success"
}
To get the ID of the newly created record, execute the following snippet:
Error
Following is an error when the user tries to insert a record with the mandatory field not filled:
{
"Task_Description":"",
"Task_Name":"Task-100"
},
"status":"Failure, Enter a value for Task Description"
}
Following is an error when the user tries to insert a duplicate record:
{
"Task_Description":"I need help installing my air conditioner",
"Task_Name":"Task-100"
},
"status":"Failure,
Duplicate values found for 'Task Description' "
}
Following is an error when the user tries to insert an text value for a field which accepts only numbers:
{
"Task_Description":"Test",
"Task_ID":"Task-100"
},
"status":"Failure,
Enter a valid number for Task ID"
}