Form Actions - Stateless Forms
Table of Contents
By default, each Form created in Zoho Creator will have a table generated at the back-end to store data submitted through the Form. For example, when you create a Contacts Form, a Contacts table is created and all data submitted through this Form will be stored in this table. Zoho Creator supports creating Stateless Forms with scriptable buttons, that does not generate a table at the backend; (i.e) when you click on the Form button, the entered data is not automatically added to a table as in the case of a Regular Form. Instead, you can add custom buttons and write Deluge script in the "On Click" event of the Form. The scripts act on the "on click" button that can be programmed to do anything you can do in Deluge script. This gives you the flexibility of storing the entered data into any Field of any record of any table in Zoho Creator. You can even use it to retrieve data from any Field in any record of any table in Zoho Creator.
Some common usage of the Stateless Forms are listed below:
Create Web Forms: Stateless Forms can act as web forms that are embedded in websites. This Form data can be submitted to any service or used to update a record in another Form/Application, without persisting data in Zoho Creator. The Deluge Get URL and Post URL task can be used to GET/POST data to external websites or other Zoho Creator Applications.
Create multiple Forms updating data in a single table: Since a Stateless Form is by definition not joined with any particular table, you can design different Stateless Forms each with a different subset of Fields in a particular table. For example, you can create one Stateless Form for the role "Technician" and another Stateless Form for the role "Manager" and share it with the respective roles but persist the data submitted from all the Stateless Forms in the same main table. This enables different users within the same organization use the different Stateless Forms to perform their assigned tasks without having access to the other fields in the Table.
Create user settings dialog for the real time apps: Create a Stateless Form to enable users to customize all the properties of an Application in one single Form. For example, add a Settings link to your app that will fetch the record for the current logged-in user and set the values in the On Load of the Stateless Form. Users can modify their settings and submit the Form. This Form will then do an update record in the main Form.
Fetch and Display information from other Forms: Create a Stateless Form to fetch and display information from other Zoho Creator Forms or from other services, based on the Form input. For instance, assume you have a Status Form in your Application to display the Status of a particular Work Order. When a user inputs their Work Order number and clicks on the Form button, the Status must be displayed. In this case, it is not necessary to store the Form data. You can create a Status Form and write On Click Form action to display the Status in a Note field.
Generate dynamic HTML page: Create Stateless Forms to generate dynamic HTML Page by passing the Form data as parameters to the Page. For example, specify the search criteria to display records from a Contacts Management Application, specify the Month and Year to display records pertaining to a specific period.
Execute Send Mail: Create a Stateless Form to execute any Deluge task like Send Mail, on click of the Form button. In addition to On Click Form actions, you can also execute On User input Field action scripts.
To create a Stateless Form without data storage,
- Select Create New -> Form option.
- In the New Form dialog, specify the Form name.
- Deselect the option Data to be stored in Zoho Creator and click Create to create the Stateless Form.
- Drag-n-drop the required Fields to the Form.
- Use the (+) link, to add Custom buttons to the Form, by specifying the button name and type.
- Custom button: On mouse click, invokes the "On Click" action of the button.
- Submit button: On mouse click or if Enter Key is pressed, invokes the "On Click" action of the button.
- Reset button: On mouse click, Form is taken to the initial state. "On Click" action cannot be configured for reset button.
- To perform any action on click of the Form button, add the required Deluge script in the Form Actions - < Form Button Name > - On Click block of the Workflow tab. For example, if you add a custom button named "Add", write the Deluge script within Form Actions - Add - On Click block of the Workflow tab.
- Click Save script to update the script.
- Click on Access this application and enter data to the Stateless Form. On click of the form button, the script added to the "On Click" block will be executed.
An existing Form in Zoho Creator can be converted to Stateless Form. For more details, please refer Normal -> Stateless Form.
Assume you have created a Contact Form to enter the contact details of your friends like Name, Address, Contact Number and Email id. Now you want to update some existing records which have the Address / Contact Number Fields as blank. To do this, you can create a Stateless Form to fetch and display data from the Contact Form (main Form), enter the required details and update this record in the Contact Form.
- Create a Stateless Form with Email Id as Lookup Field from the Contact Form and other required fields, as shown in the screen-shot given below:
- Add On User input script to the Email_Id field of the Stateless Form, to fetch the corresponding record from the Contact Form and display it in the current Form. Refer On User input script highlighted in the Form Definition given below.
- When an Email id is selected, the corresponding record is fetched from the Contact Form and displayed in the Stateless Contact Form, as shown in the screen-shot below.
- Update the record with the desired values and click on the Update button. The modified values will be updated in the Contact Form. This is achieved by writing action script to update the record in the Contact Form. The script is added to the Form Actions - Update -> On Click block. Refer the code highlighted in the Form Definition given below.
store data in zc = false
displayname = "EmailId"
type = picklist
values = Contact.Email_Id
on user input
r = ContactForm [Email_Id == input.Lookup_1];
input.Address = r.Address;
input.Contact_Number = r.Contact_Number;
input.Name = r.Name;
type = text
type = textarea
displayname = "Contact Number"
type = number
width = 20
type = button
displayname = "Update"
r = ContactForm [Email_Id == input.Lookup_1];
r.Name = input.Name;
r.Address = input.Address;
r.Contact_Number = input.Contact_Number;
type = button
displayname = "reset"