How To: Use the Post Initialize Event
You can use the Post Initialize event and method for example where a form is initialized and is required to be available to the user while still performing other rule actions such as load methods and get list methods on the form. You can also use it on views or forms with control rule actions that are executed asynchronously. The view or form will initialize and controls can execute asynchronously post initialization to ensure immediate availability of the view or form and enhance performance.
You can use the Initialized event and method with the following events and actions:
Type | Description |
---|---|
Event | When the Form raises an event |
Event | When a View raises an event |
Action | Execute a View method |
Action | Execute a Form method |
Following is an example of how to use the Initialized event. The same principle applies when using the Initialized method. The scenario below applies to a form containing a Sales Item view. The view contains a CustomerID drop-down list and a ProductID drop-down list, both which need to be populated at runtime. We use the When the Form is Initializing rule event to populate the CustomerID drop-down list, and the When a View executed Initialized rule event to populate the ProductID drop-down list, in other words post initialization. The sequence of the rule definition execution is explained below:
The form is initializing, then the Sales Item view is initializing and the Customer drop-down list populated with data. At this stage the view and form is available for editing and the user can start typing data into the view and access the list of customers. After the view has initialized (post initialization), the Product drop-down list is populated with data, meaning while the user is capturing data the Product drop-down list is populated. This rule definition ensures that you can continue using views and forms while other rule definitions are still being executed.
The rule definitions are executed in the order the images are listed.
- The Initialized event always executes after the related Initialize event, regardless if there are user actions configured for the Initialize event or if the Initialize event is disabled. Initialized always executes after Initialize even if Initialized is called from any other rule. See the note at the top of this page for information about the relation between the Initialize and Initialized events.
- When you add or remove theWhen the View executed Initialized event (Initialized) on a form and the When the View executed Initialize event (Initialize) exists on the view contained within the form, the Initialized event executes when the Initialize event has completed.
- When you have aWhen the View executed Initialized event (Initialized), When the View executed Initialize event (Initialize), When the Form is Initialized event (Initialized), and When the Form is Initializing event (Initialize), the view and form execution happens independently. The form execution does not wait for the view execution to complete.
- Use the initialize and initialized rules to improve performance on the initial load of a form (when the form opens for the first time). When you use these rules after a form has initially loaded, for example when you click a button, you may experience unexpected or different behavior. Consider the following when using these rules
The rules are dependent on the state in which the view or form is when the view or form loads. If the form state changes and the rules execute, the behavior may be different to when you first load the view or form.
It is recommended to use these rules when you first load a view or form to improve performance. For greater control and visibility you can separate actions and conditions into separate rules.
When you use the initialize and initialized rules together they create a chain. If you want to execute advanced actions and conditions or want to specify that rules execute in an exact order you must rather use the Execute another rule action and Unbound rule concepts.