Saving user preferencies on APEX

Search for a command to run...

Oracle APEX already includes Font APEX as the default icon library for Universal Theme. In most cases, that is enough. But in one of my APEX apps, I needed a few icons that were not available there, s

Looking to give your Oracle APEX mobile app a modern, native feel? Here’s a quick hack: add a floating action button that stays anchored at the bottom corner just like in popular mobile apps. This sma

APEX 26.1 has been updated to the Universal Theme. While much of the attention in this release is on AI features, I think the UT improvements are just as important for developers like me who care abou

The apex_barcode package offers a PL/SQL API to generate various types of barcodes. You can output barcodes as SVG (Scalable Vector Graphics) values or as PNG file blobs, making it easy to embed them

Oracle APEX makes it easy to get data on screen fast, but often, the default tabular output isn’t enough. What if you want to highlight statuses, add icons, or display badges all without writing compl

Many apps offer options for users to personalize the appearance and functionality of the app and developers commonly utilize tables to store these customizations.
One of the many features that APEX provides is the APEX_UTIL package, which includes a variety of useful functions and procedures to enhance application development. Among these functions, APEX_UTIL.SET_PREFERENCE stands out as a convenient tool for saving application preferences efficiently without the need to create tables or new columns.
To save a user preference, we have the choice to execute the following code either through PL/SQL, utilizing a page process known as User Preferences or a page computation.
In the example below, we will save the user's preferred choice for viewing a calendar.
BEGIN
APEX_UTIL.SET_PREFERENCE(
p_preference => 'CALENDAR_VIEW',
p_value => :P1_CALENDAR_VIEW,
p_user => :APP_USER);
END;
We also have the option to use a User Preference page process after submitting on the processing point to save that.

To retrieve the saved preference value and use it for customizing the app when users visit the calendar page, we can also utilize either PL/SQL, a page process or a computation.
BEGIN
:P1_CALENDAR_VIEW := APEX_UTIL.GET_PREFERENCE(
p_preference => 'CALENDAR_VIEW',
p_user => :APP_USER
);
END;
If we want to use a computation we can use as follows.

If we decide to eliminate the functionality or no longer want to save or maintain the user preference within the given context we can just delete the preference
BEGIN
APEX_UTIL.REMOVE_PREFERENCE(
p_preference => 'CALENDAR_VIEW',
p_user => :APP_USER);
END;
If you are still using tables as a means to store customizations specific to individual users, it is highly recommended that you begin utilizing the user preferences feature. This feature offers a more efficient and streamlined approach to managing user-specific settings and preferences.