A background form is just like any other form except that it is opened 'Hidden' so the user does not see it. Normally hidden forms are created to perform a set of tasks or calculations for the parent form, which is interacting with the user. This allows the parent form to access and process data from other tables or the same table to perform a calculation or task.
The 3 most common background form types are listed below.
- Execute a Single Task Using the 'onInit' Trigger.
- Opened as hidden by a parent form.
- Perform a single onInit() task.
- Close the form without prompting the user.
- Execute Multiple Tasks.
- Opens with the parent forms and then can be used when needed by the parent form.
- The close task on the parent form closes the background form.
- System Tasks (Available to All Forms).
- Perform system level tasks and close when the application closes.
Execute a Single Task Using the 'On Open' Trigger
In this method, calculations or tasks are handled when the background form is opened using the On Open or On Int trigger. In this case the task runs immediately and once it is complete the background form is closed.
- In the background form, create the task you wish to run when the form is opened.
- Add the Close action as the final step in the task.
- Add your action chain to the On Open or On Int trigger for the background form. This method can be useful for checking for duplicates, updating multiple records, copying records, etc.
Execute Multiple Tasks
In this method, the background form will be opened when the parent form is opened and closed when the parent is closed. The benefit of this approach is that the parent form has complete control and can use tasks and data in the background form as needed.
System Tasks (Available to All Forms)
In this method, the background or startup form will open and close with the application. This is useful for performing system wide calculations and setting permission levels.
Chaining Forms in the Background
It is quite common for a background form to open additional background forms to support the task it needs to perform. The same process outlined in this article is used when a background form opens additional background forms.
Use a Background Form to Check for Duplicate Records
In this example, we are using a background form to evaluate if the new user entered into this pop-up form will create a duplicate record.
See the article on Creating Pop-Up Forms.
Configure the Parent Form
The save task performs a series of steps to evaluate if the values entered match any existing records before it saves the data.
Configure the Background Form
Open Background Form
Once the background form is created and the action you want it to perform added, the parent form needs to open the form as hidden. This is accomplished by utilizing the Open Form action and selecting the hidden option.
The background form will have an on initialization trigger to check if there are records in the grid.