Tuesday, August 28, 2012

APEX Shortcuts

One page that always eludes me when I need it is the Application Build Status page. When I need to quickly set an application to unavailable so I can update the backend for instance, I spend 10 minutes trying to find it only to give up and edit the table in the apex schema. Well not so any more.

On the Administration page there is a yellow announcement bar you can edit and add links to. Since the #SESSION# substitution doesn't work you have to use a javascript link, but it's not too hard to figure out. Here's the HTML for my Application Build Status shortcut.

<a href="javascript:document.location.href='f?p=4350:41:'+$('#pInstance').val()">
  <b>Application Build Status</b>
</a>


The internal workspace also has an instance wide announcement bar that works the same way.

Sunday, July 8, 2012

Button Confirmation Message

This is a quick way to add a javascript confirmation message to a button.

Firstly make sure that your button template uses #BUTTON_ATTRIBUTES# substitution string (note  #BUTTON_ID# doesn't seem to work as expected here). Add a button id to the Attributes field, or otherwise ensure you can identify it with a jQuery selector.


Then in Post Element Text place some jQuery to extend the click event...


I figure this method should be pretty robust. Here's the code for copy/pastability:

<script>
var btnClick = $('#PX_MYBUTTON').attr('onclick');
$('#PX_MYBUTTON')
 .removeAttr('onclick')
 .unbind('click')
 .click(function(e){
  if (confirm('Confirm message.')) btnClick(e);
 });
</script>

Tuesday, May 8, 2012

Interactive Report Column Custom Formatting

The question was posed, how to achieve custom formatting of a column if the available Format Models don't suffice? In standard SQL reports, it's not such a problem as you can simply use the "HTML Expression" field.

Well here's one way to do it, use some jQuery in a dynamic action. While this may seem really counter-intuitive, it's actually both beautifully simple and reliable after you finish considering all the other available options. Plus, that's what this blog is all about remember (when it's not being abandoned for years).

Create the dynamic action called something like "Format Report" triggered "After Refresh" on the report region. Also ensure "Fire On Page Load" is checked. The action is to execute Javascript like the following (this example will give you a trailing "%"):

$('td[headers="MY_COLUMN"]').append('%');

UPDATE: Or better yet...

$('td[headers^="MY_COLUMN"]').text(function(index,text){return text+'%'});

After teething problems with the first use case, we figured out you must have a Region Template with id="#REGION_STATIC_ID#". Also we adapted the jQuery to better support several other IR features (as seen in the second option above). Leave comments if you can build on this any further.

The advantage here is you don't have to modify the query and you can put all sorts of additional formatting in the one place without interfering with the existing functionality of the interactive report.

Here's another possible solution. The iFormat™ deluxe model. While both effective and platform independent, mounting and unmounting required to apply the formatting may prove somewhat arduous for the users after a while.