APEX shortcut variables

APEX shortcut variables are best in dynamic use in Javascript code. We can fetch data from database or can use any hard coded text.

Use a shortcut to define frequently used code once and then reference it in many places thus reducing code redundancy. For example, you can create a shortcut to define a page control such as a button, HTML text, a PL/SQL procedure, or HTML.

You can use a shortcut within the following locations:

  • The Region Source attribute of regions defined as HTML Text (with shortcuts).
  • Region Header and Footer Text attribute.
  • Item Label attributes, Pre Element Text, Post Element Text, and Default Value attribute.
  • Region Templates attributes.

Under the shared components we have pretty awesome feature of APEX shortcut. 

  • We have several source types available to populate the shortcut variables. * PL/SQL Function body
    • HTML Text
    • HTML Text with Escaped Special Chars
    • Images
    • Text with JavaScript Escaped Special Chars
    • Message
    • Message with JavaScript Escaped Single Quotes

PL/SQL function can be followed by:

CREATE OR REPLACE FUNCTION get_date
   RETURN DATE
AS
BEGIN
   RETURN SYSDATE;
END get_date;

Two types of common shortcuts can be like below.

1). HTML

2). PL/SQL

Scope declaration

var plsql_msg = '"PLSQL_MSG"';
var html_msg = '"HTML_MSG"';

These variables can be used in JavaScript for multiple purposes.

alert(html_msg);
alert(plsql_msg);