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 fires after the Initialize event regardless if there are user actions configured on Initialize or if the Initialize event is disabled or not. Initialized will execute after Initialize even if Initialized is called from any other rule.
- When Initialized is added or removed on different levels, other definitions are not affected. If it exists and the related Initialize event has completed it will run automatically.