Apex: Dynamically formatting on the navigation bar (Universal Theme)

Requirement 

This is a simple way to add formatting to the nav bar. In this case I'm dynamically adding a number to one of the labels.

Solution 

Create an application item.

 

 Create an application computation using a SQL Query.

select decode(count(*),0,'Updates', '<p><span style="color: rgb(184, 49, 47);"><strong><span style="background-color: rgb(184, 49, 47);">&nbsp;</span></strong></span><span style="color: rgb(255, 255, 255);"><strong><span style="background-color: rgb(184, 49, 47);">'||count(*)||'</span></strong></span><span style="color: rgb(184, 49, 47);"><strong><span style="background-color: rgb(184, 49, 47);">&nbsp;</span></strong></span> Updates</p>') countx 

etc..


In other words, display "Updates" in some conditions, in others display a coloured number before the word. I've chosen a bold red colour.

Now open the Navigation Bar template. You'll notice that all the labels have a button label set to TEXT_ESC_SC. (Escape Special Characters). The template references this field 8 times


..

Change all of these references from TEXT_ESC_SC to just TEXT


Apply this technique to any other item on the menu bar where you want to dynamically use HTML formatting to highlight something.


Comments