Quick tip: default only for new records

If you have an ordinary Oracle APEX form with the standard Automatic Row Fetch process, and the page has an optional item with a default value, APEX will set the default on new records automatically. However, if the user queries an existing record, Oracle APEX will also fill in a missing value with the default value. This might not be what is desired – if the user clears the value they would expect it will stay cleared.

If you only want the default to be applied for new records, change the attribute on the item so that the default is only applied to new records:

  1. Set Default Value Type to PL/SQL Expression
  2. Set Default value to something like:
    case when :P1_ID is null then 'xyzzy' end

Comments

  1. How does the Default Value process work’s in Interactive grid.

    When i want to Insert a Record, the Default Values are shown, but when press the Save Button, some Values are used ( for Column Type’s: Date) others are not working ( Column Type: Number).

    Regards Volker

    PS.:
    Working with Version 24.2.9 (and tried to download the Patch 12, but the shown Link / Link’s to the Patches, does not work since serveral week’s.
    The new MOS does also not help ( for nothing at all )

    • Hi Volker,

      I think you can use the same method for an Interactive Grid although I haven’t tried it; you would use a similar expression except you don’t refer to a page item, instead you would refer to a column in the grid, e.g. case when :ID is null then 'xyzzy' end

Leave a Reply

Your email address will not be published / Required fields are marked *