When building Oracle Forms applications, understanding the sequence of triggers is critical. One of the earliest triggers to fire during form startup is the PRE-FORM trigger. It is often compared with the WHEN-NEW-FORM-INSTANCE trigger, but they serve different purposes.
In this article, I will explain what the PRE-FORM trigger is, when it fires, how to create it, and give you practical examples and best practices.
What is the PRE-FORM Trigger?
The PRE-FORM trigger fires once before the form is displayed to the user.
- It executes before the first block and item are initialized.
- It is often used to set global variables, initialize environment settings, or customize runtime properties.
- It is the first opportunity to programmatically influence how the form will behave after it loads.
👉 Think of PRE-FORM as the “preparation stage” that gets executed right before the form becomes visible.
When Does PRE-FORM Fire?
The firing sequence of a form is:
- The form is called.
- PRE-FORM fires.
- Oracle Forms prepares the runtime environment.
- WHEN-NEW-FORM-INSTANCE fires.
- The user gains control of the form.
So, PRE-FORM comes earlier than WHEN-NEW-FORM-INSTANCE.
How to Create a PRE-FORM Trigger
- Open your form in Oracle Forms Builder.
- Go to the Object Navigator.
- Expand the Form Triggers node.
- Right-click and choose Create → Trigger.
- Select PRE-FORM from the list.
- Add your PL/SQL code in the trigger editor.
- Save and compile the form.
Example 1: Setting Global Variables
BEGIN
:GLOBAL.USER_ID := USER;
:GLOBAL.APP_DATE := SYSDATE;
END;
- Initializes global variables with the current database user and system date.
- These values can be used in multiple forms during the session.
Example 2: Customizing Runtime Properties
BEGIN
SET_WINDOW_PROPERTY(FORMS_MDI_WINDOW, TITLE, 'Student Management System');
END;
- Changes the title of the main application window before the form is shown.
Example 3: Environment Initialization
BEGIN
:PARAMETER.FORM_MODE := 'ENTRY';
IF :PARAMETER.USER_ROLE = 'ADMIN' THEN
SET_APPLICATION_PROPERTY(CURSOR_STYLE, 'BUSY');
END IF;
END;
- Sets default form parameters.
- Applies conditional logic based on user roles.
Example 4: Pre-Query Setup
BEGIN
:GLOBAL.SESSION_ID := TO_CHAR(DBMS_RANDOM.VALUE(1000,9999));
:GLOBAL.START_TIME := SYSDATE;
END;
- Generates a session ID and captures the session start time.
- Useful for logging and auditing.
Best Practices for Using PRE-FORM Trigger
- Use it for environment and session initialization, not data manipulation.
- Keep code lightweight—heavy logic here can delay form loading.
- Use it in combination with WHEN-NEW-FORM-INSTANCE:
- PRE-FORM → setup environment.
- WHEN-NEW-FORM-INSTANCE → initialize form data.
- Avoid navigating to blocks or items here; the form is not fully ready.
PRE-FORM vs WHEN-NEW-FORM-INSTANCE
| Feature | PRE-FORM | WHEN-NEW-FORM-INSTANCE |
|---|---|---|
| Fires | Before form display | After form display |
| Purpose | Environment & global initialization | Form-level initialization |
| Can navigate blocks/items | ❌ Not safe | ✅ Allowed |
| Common use | Set globals, environment setup | Default values, queries |
Conclusion
The PRE-FORM trigger is an essential part of Oracle Forms development. It gives you the first chance to set up the environment, assign global variables, and prepare runtime properties before the user ever sees the form. When combined effectively with the WHEN-NEW-FORM-INSTANCE trigger, it provides a strong foundation for clean, well-structured form behavior.
By mastering this trigger, you can build forms that start smoothly, consistently, and in line with your application’s requirements.

