Understand sub form actions
The subform actions are a set of actions that concern the subform. In the live application, the subform will have two buttons:
- 'Add new' - This button will enable the user to add a new entry to the subform.
- 'Delete' - This button will enable the user to delete an entry in the subform.
By default, both the 'Add new' and 'Delete' buttons will be displayed. However, a workflow can be used to show or hide the buttons. Using a workflow you can set conditions and display the buttons to the user. The button is displayed in the subform only when the condition evaluates to true.
Under the subform actions there are four different options:
- Show subform add entry - This will show the 'Add new' button
- Hide subform add entry - This will hide the 'Add new' button
- Show subform delete entry - This will show the 'Delete' button
- Hide subform delete entry - This will hide the 'Delete' button
Let's assume that a company is collecting the information of its employees and the vehicles they own. The form has a field for the employee name, email and number of vehicles. If they have vehicles then the employee should enter their details which is present as a subform. The company wants to design the form in such a way that the employees with no vehicles need not fill the fields in the subform. This can be achieved by creating a workflow which runs the 'Hide subform add entry' action on the condition that number of vehicles is zero. When the employees enter '0' in the 'No. of vehicles' field then the 'Add new' button will be hidden. They can then proceed to submit the form. Assume that the company does not want the employees to delete the entries which they entered in the 'Vehicle details'. This can be achieved by creating a workflow which runs the 'Hide subform delete entry' action with the always condition. This will remove the delete button for all employees. Similarly the company can use the other options based on the necessary criteria.
Note: There are differences between the show/hide options that are available in the forms and the subforms. The show/hide option in the form focuses on whether to display a field present in a form. While the show/hide option in the subform focuses on whether to allow the user to add or delete new entries to the subform.