Using Groups in Application Express

By: Chris Ostrowski

There’s not a lot of documentation regarding groups in Oracle Application Express, but I found an easy way to hide page elements based on group memberships.

Let say you have a form with a “Create” button, but you only want “power” users to be able to create records. Here’s an easy way to do it without having to write a lot of code:

Step 1: In the Administration dropdown for your application, select Manage Users and Groups. Select the Groups tab and then “Create User Group”. Call the new user group “PowerUsers”.

Apex 1

 

 

Apex 2

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 2: Edit one of your users (or create a new one) by selecting the Users tab. Click the pencil next to a user and scroll down the User Groups section at the bottom of the page. Assign the user to the “PowerUsers” group and click “Apply Changes”.

Apex 3

 

 

 

 

 

Step 3: Edit the page with the form. Double click on the “Create” button and scroll down to the “Conditions” section. Change “Condition Type” to “PL/SQL Function Body Returning a Boolean” and add the following code in the Expression 1 code box:

declare val boolean;

begin

val := apex_util.current_user_in_group(p_group_name=>’PowerUsers’);

return val;

end;

 

Apex 4

 

 

 

 

 

 

 

 

 

 

 

 

 

Apex 5

 

 

 

 

 

 

 

 

That’s all there is to it! If you run the page logged in as a user that is a member of the “PowerUsers” group, the “Create” button will be displayed. If the current member is not a member of the “PowerUsers” group, the button will not be displayed.