APEX 5 Saved Interactive Reports – Primary Report Name Change

I had a requirement today to use the Saved Reports feature of APEX to create a list of reports for users to pick from. The issue was with the default report name. We wanted the name to reflect what the report was designed for. Showing a label of “All Data” was mare appropriate for the default report rather than the given “1. Primary Report” label.

IR-PRI-default

Messages and Translation

As with many things software, there is almost always more than one way to accomplish a result.

In Oracle, you can change most of the text options using translations. Oracle invests a lot of effort in supporting multi lingual implementations. If this is your situation also, I strongly recommend using the translation mechanic to change the default text. Even if you only develop in one language, you can leverage this capability.

Creating a Text Message with the value of APEXIR_PRIMARY_REPORT will change the listing for the “PRIMARY REPORT” label on ALL interactive reports across your application.

IR-PRI-text-message

The value entered for the translation will apply to all interactive reports in your application

IR-PRI-text-message-result

Change to different values per Interactive report

If your use case is to have the default report named differently on each interactive report instance, you have an option to adjust the listing using Dynamic Actions and a bit of JavaScript.

Create a dynamic action on the Interactive Report region – for the After Refresh event.
IR-PRI-da-event

Add an execute JavaScript action.
IR-PRI-da-action

The concept of the JavaScript is to locate the report list and re-name the un-translated APEX provided name to a custom value.

var my_primary_report_name = 'My Name of Choice';

$('#'+this.triggeringElement.id+' .a-IRR-selectList').find('option').each(function(index,elem){
  $(elem).text(function(i,text){
    return text.replace('1. Primary Report',my_primary_report_name);
  }); // end of text change
}); // end of option walk

This JavaScript code executed in a Dynamic Action – can reference the REGION_ID, allowing each interactive report implementation to have a different name.

IR-PRI-text-message-result-new

References

Documentation
Full list of text replacements in Oracle Documnets
Inspiration and Similar Posts
Stack Overflow – Post with similar methodology for 4.2

2 thoughts on “APEX 5 Saved Interactive Reports – Primary Report Name Change

  1. Hello Tim,

    In the javascript code your report name is still hardcoded.
    If you create a shortcut in your Apex application as a “Message with Javascript escaped single quotes”, you can use it in Javascript together with the translatable Text message.

    For example:
    The shortcut is named MY_PRIMARY_REPORT_NAME_SC.

    In Javascript you can reference it like:
    var my_primary_report_name='”MY_PRIMARY_REPORT_NAME_SC”‘;
    Notice the double quotes!

    Finally create a text message called MY_PRIMARY_REPORT_NAME_SC for each language you need a report name.

    Regards,

    Mathieu

  2. Mathieu,

    Thank you for your input. There are several ways to deal with the translations of static text. This is also a consideration with ANY saved public report.

Leave a Reply

Your email address will not be published. Required fields are marked *