Dynamic APEX Logo

I was tasked with creating a dynamic logo for our APEX site. The application was branded in different ways and it didn’t look quite right having a “LOGO” written there, and adding another image was a bit overkill. So instead we wanted to have “Hi Employee!” as the logo whenever someone logged in.

Normally a nice and easy thing to do anywhere else on an APEX application, but the process is slightly different for the logo region.

Things we need:

  • Application Process
  • Application Item

You can find the Application Process and Application Item options in Shared Components. Let’s create the Application Item first.

Name: P0_EMP_NAME
Scope: Application
Session State Protection: Restricted - May not be set from browser

And click Create Application Item. That’s all there is to this.

Click on Application Process to create the query to get the employees name. The process we are creating will happen every time on page load, returning the value of the query into an application item which we can use for a substitution string.

Name: EMP_NAME
Sequence: 1
Point: On Load: Before Header (page template header)
Condition: Current Page != Expression 1 = [LOGIN PAGE NUMBER]

Edit: I forgot to include the condition before.

Update: Marko Goricki has kindly commented on my blog with some improvements. He is correct in saying that that having it run on every page load isn’t very efficient, and moving it to a post-authentication procedure or at least making it run if :P0_EMP_NAME is null would be better. Please see his comment here:

You could optimize it by putting this PL/SQL code to the After Authentication Process or in the Post Authentication procedure of your authentication scheme (or at least give it a condition to run it when :P0_EMP_NAME is null) so it won’t not be called at every page load.

The PL/SQL code is something like this:

begin
select
'Hi ' || EMPLOYEE_NAME || '!' as EMPLOYEE_NAME
into
:P0_EMP_NAME
from
EMP_TABLE
where
:P0_EMP_NAME is null and USER_NAME = :APP_USER;
end;

This creates the sentence I want to be displayed in the Logo area dynamically, using the employee’s name instead of their login details.

And the last thing to do now is to go into Shared Components > User Interface Attributes > Logo > Make sure it’s set to text and enter: &P0_EMP_NAME. – (Don’t forget the trailing .)

And that should be you finished!

Dynamic Logo

4 thoughts on “Dynamic APEX Logo

  1. Hi!

    You could optimize it by putting this PL/SQL code to the After Authentication Process or in the Post Authentication procedure of your authentication scheme (or at least give it a condition to run it when :P0_EMP_NAME is null) so it won’t not be called at every page load.

    Btw. it’s strange to call application item with P0_*. because in most cases you have a global page 0 and they are not the same. You said that application items are like hidden items on every page and that’s not true. Application items are not generated in HTML DOM so you can’t use them in JavaScript (Dynamic Actions).

    Br,
    Marko

    Like

    1. You are correct, that would be a better optimization. I’ll edit my post to include that, thanks!

      My team and I have always used P0 to indicate that it doesn’t sit on a particular page, but again, you are right to say that would make sense for the global page as that is Page 0. Perhaps this requires us to take another look at our code standards 🙂

      Thanks for explaining my misunderstanding here. I will edit the post to remove that as I don’t want to misinform people. But thank you for explaining the difference to me.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s