How to Change Item Properties at Runtime in Oracle Forms

Oracle Forms provides developers with a powerful way to build interactive and dynamic applications. Often, you need to change how items (such as text fields, checkboxes, or buttons) behave depending on user actions, data values, or business rules. This is achieved by modifying properties at runtime.

In this article, we will explore how to Change Item Properties at Runtime in Oracle Forms, discuss the built-ins available, provide practical examples, and highlight best practices for creating responsive forms.


What Are Item Properties in Oracle Forms?

Item properties define how an element (text item, checkbox, radio button, etc.) looks and behaves. Some examples include:

  • Enabled/Disabled – Controls whether the user can interact with the item.
  • Visible/Hidden – Determines if the item is displayed on the canvas.
  • Prompt Text – The label that appears next to an item.
  • Required – Forces users to enter a value before saving.
  • Visual Attribute – Controls colors, fonts, and styles.

Changing these properties dynamically allows your application to react to user actions in real time.


Built-ins for Changing Item Properties

Oracle Forms provides two main built-ins for runtime property changes:

  1. SET_ITEM_PROPERTY
    • Used to change the properties of items at the block level.
    • Example properties: ENABLED, VISIBLE, REQUIRED, PROMPT_TEXT, VISUAL_ATTRIBUTE.
  2. SET_ITEM_INSTANCE_PROPERTY
    • Used to change properties for specific records in a multi-record block.
    • Example properties: VISUAL_ATTRIBUTE, UPDATE_ALLOWED, NAVIGABLE.

Using SET_ITEM_PROPERTY

The SET_ITEM_PROPERTY built-in changes a property for an item across all records in a block.

Syntax:

SET_ITEM_PROPERTY(item_name, property, value);

Example 1: Enable or Disable an Item

BEGIN
   SET_ITEM_PROPERTY('EMP_BLOCK.SALARY', ENABLED, PROPERTY_FALSE);
END;
  • Disables the SALARY field for all records in the block.

To re-enable:

BEGIN
   SET_ITEM_PROPERTY('EMP_BLOCK.SALARY', ENABLED, PROPERTY_TRUE);
END;

Example 2: Change Prompt Text at Runtime

BEGIN
   SET_ITEM_PROPERTY('EMP_BLOCK.SALARY', PROMPT_TEXT, 'Monthly Salary');
END;
  • Updates the label of the SALARY item to “Monthly Salary”.

Example 3: Hide or Show an Item

BEGIN
   SET_ITEM_PROPERTY('EMP_BLOCK.BONUS', VISIBLE, PROPERTY_FALSE);
END;
  • Hides the BONUS field completely from the form.

Using SET_ITEM_INSTANCE_PROPERTY

When working with multi-record blocks, sometimes you only want to change properties for a single record instead of all records. This is where SET_ITEM_INSTANCE_PROPERTY comes in.

Syntax:

SET_ITEM_INSTANCE_PROPERTY(item_name, instance, property, value);

Example 1: Change Visual Attribute for Current Record

BEGIN
   SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.SALARY', CURRENT_RECORD, VISUAL_ATTRIBUTE, 'VA_HIGHLIGHT');
END;
  • Highlights the salary field of the current record using a predefined visual attribute (VA_HIGHLIGHT).

Example 2: Make a Field Non-Navigable for Specific Record

BEGIN
   SET_ITEM_INSTANCE_PROPERTY('EMP_BLOCK.COMMISSION', CURRENT_RECORD, NAVIGABLE, PROPERTY_FALSE);
END;
  • Prevents navigation into the COMMISSION item in the current record only.

Practical Use Cases

  1. Dynamic Form Behavior
    • Hide or disable fields based on user roles.
    • Example: Managers can update salaries, but clerks cannot.
  2. Conditional Formatting
    • Highlight records that meet certain criteria.
    • Example: Salaries above 10,000 displayed in bold red.
  3. User Guidance
    • Change prompts or display messages depending on input.
    • Example: Change field prompt from “Discount” to “Special Discount” if customer type = VIP.
  4. Validation Assistance
    • Mark invalid fields with a different background color.
    • Example: Change visual attribute if an entered value is out of range.

Commonly Used Properties with SET_ITEM_PROPERTY

PropertyValue OptionsDescription
ENABLEDPROPERTY_TRUE/FALSEEnable or disable input
VISIBLEPROPERTY_TRUE/FALSEShow or hide the item
REQUIREDPROPERTY_TRUE/FALSEMake input mandatory
PROMPT_TEXTString valueChange the label of the field
VISUAL_ATTRIBUTEVisual Attribute nameApply colors, fonts, and styles
UPDATE_ALLOWEDPROPERTY_TRUE/FALSEControl update permissions

Best Practices for Runtime Property Changes

  • Plan attributes in advance: Define visual attributes in Object Navigator for consistency.
  • Avoid overuse: Too many runtime changes can confuse users.
  • Combine with triggers: Use triggers like WHEN-NEW-RECORD-INSTANCE or WHEN-VALIDATE-ITEM for dynamic control.
  • Test for performance: Excessive property changes in multi-record blocks can slow down navigation.
  • Maintain consistency: Ensure that users clearly understand which fields are editable and why.

Common Errors to Watch Out For

  • FRM-41009: Function cannot be performed here
    • Happens if you try to change a property inside an invalid trigger.
  • FRM-41084: Error during SET_ITEM_PROPERTY
    • Usually caused by referencing a wrong item name or using an invalid property.
  • Inconsistent UI
    • Forgetting to reset properties when conditions change may leave items in the wrong state.

Conclusion

Being able to Change Item Properties at Runtime in Oracle Forms allows developers to create highly dynamic, responsive, and user-friendly applications. By using built-ins like SET_ITEM_PROPERTY and SET_ITEM_INSTANCE_PROPERTY, you can control visibility, accessibility, prompts, and formatting of items based on user roles, conditions, or business rules.

When applied carefully with best practices, this feature enhances usability and ensures that your Oracle Forms applications remain flexible and intuitive.

Vinish Kapoor
Vinish Kapoor

Vinish Kapoor is a seasoned software development professional and a fervent enthusiast of artificial intelligence (AI). His impressive career spans over 25+ years, marked by a relentless pursuit of innovation and excellence in the field of information technology. As an Oracle ACE, Vinish has distinguished himself as a leading expert in Oracle technologies, a title awarded to individuals who have demonstrated their deep commitment, leadership, and expertise in the Oracle community.

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments