In Oracle APEX, you can create interactive classic reports that allow users to select a record and pass its values into a page item, without refreshing the whole page. One common case is setting an item like :P5_ID
When a user clicks on a value (like ID
) in a report.
Let’s explore how to do it using a custom SQL query and JavaScript.
I have the following page :
You can partial page refresh by changing the query from :
select
ID,
NAME,
NAME_NL,
SNAME,
ENTRY_BY,
ENTRY_DATE,
UPDATE_BY,
UPDATE_DATE,
BRANCH
from DESIGNATION;
It will refresh the Region :
select
'<a href="f?p=&APP_ID.:5:&SESSION.::NO::P5_ID:' || ID || '">' || ID || '</a>' AS ID,
--ID,
NAME,
NAME_NL,
SNAME,
ENTRY_BY,
ENTRY_DATE,
UPDATE_BY,
UPDATE_DATE,
BRANCH
from DESIGNATION;
It will not refresh anything, not even the region, because of
using JavaScript:
select
'<a href="javascript:$s(''P5_ID'',''' || ID || ''');">' || ID || '</a>' AS ID,
NAME,
NAME_NL,
SNAME,
ENTRY_BY,
ENTRY_DATE,
UPDATE_BY,
UPDATE_DATE,
BRANCH
from DESIGNATION
The above query will set value to the item :P5_ID from ID in the query.
Now set dynamic action at :P5_ID
True Action :
Additional Setup
-
In the Classic Report column settings for
ID (link)
:-
Set “Escape Special Characters” to No.
-
-
Make sure the page item
P5_ID
exists on the page.
PLSQL CODE DYNAMIC ACTION :
BEGIN
SELECT NAME,NAME_NL,SNAME
INTO :P5_NAME,:P5_NAME_NL,:P5_SNAME
FROM DESIGNATION
WHERE ID=:P5_ID;
END;
ITEMS TO RETURN : P5_NAME,P5_NAME_NL,P5_SNAME
ITEMS TO SUBMIT : P5_ID
--------------------------------------------------------------
Control Button by Javascript. Use case in Dynamic Action.
First Set Button Static ID
Go to the button's properties in Page Designer.
Find Static ID under Advanced section.
Set it to something like:
SAVE
orCREATE
Example JavaScript to Control Buttons
🔹 Enable the Save button:
$('#SAVE').prop('disabled', false); // Enable
🔹 Disable the Create button:
$('#CREATE').prop('disabled', true); // Disable
Replace 'SAVE'
and 'CREATE'
with the Static ID of your buttons, not their names or labels.