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.
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.
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:
'Hi ' || EMPLOYEE_NAME || '!' as EMPLOYEE_NAME
:P0_EMP_NAME is null and USER_NAME = :APP_USER;
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!