These are all "hacks" that I have spent countless of hours on realizing because of the abundant and often contradictory information found on the internet (stackxchange, etc.), but also erroneous solutions generated by, e.g., ChatGPT.
- Authentication
- Custom Auth for own user database
- OpenID (Keycloak) for authentication
- Sources to start:
Current user shall be able to edit report rows based on condition(s).
- Context: The example is based on an IR sourced from a regular table, the editing takes place via a modal dialog.
- Edit Condition: OPEN_ID column contains same user name as current user name.
- Style: Edit column with pencil style icon to edit rows where authorized in a modal dialog1.
The built-in link attribute of a page body doesn't do the job, because with its condition statements, the whole link column is either turned on or off, no can do for individual rows. That's why it has to be done with a combination of SQL and a helper column that will contain the conditional edit buttons.
The SQL in the report page body selects the existing table data and creates the helper column EDIT_LINK
. The column is empty where the condition is not met, it contains the URL (via apex_page.get_url()
2) and the icon (fa-edit) where the condition is met.
select *,
CASE lower(OPEN_ID)
when lower(:APP_USER) THEN
'<a href="'||apex_page.get_url(p_page => '<modal dialog page id>', p_items => 'p<modal dialog page id>_id', p_values => ID)||'"><span class="fa fa-edit"></span></a>'
ELSE NULL
END EDIT_LINK
from <table name>
The column text is
EDIT_LINK
Column settings:
This is a topic I found especially hard to deal with: I want to set a creation date in a table when the entry is actually created. Doing this with a table setting of column and default value, it somehow produced an empty cell. So I found the following solution:
- Go to modal page
- Create a process in category Processing named, e.g., Set Value of type Execute Code. It should be put after the standard modal form proceses Process Form.
- Enter the following PL/SQL Code:
I wanted to have a creation time, so, for modal dialog page 3 (P3_CREATED_ON refers to CREATED_ON on the source page and from there to the source table column of the same name):
:<modal dialog var> := <desired value>;
If you want to execute SQL:5:P3_CREATED_ON := sysdate;
update <table name> set <column name> = <desired value> where <PK id variable name>= :<modal dialog ID variable name>;
The message can be styled (I didn't figure out how to suppress it completely) via a theme JS API.6 The code simply needs to be put into the events of the modal dialog page's source page, unter Page Load, as a Dynamic Action the Action Type of which should be Execute JavaScript Code.
Footnotes
-
https://forums.oracle.com/ords/apexds/post/how-to-open-modal-dialog-page-from-hyperlink-6555 ↩
-
https://docs.oracle.com/en/database/oracle/apex/22.1/aeapi/GET_URL-Function.html ↩
-
https://forums.oracle.com/ords/apexds/post/how-to-make-link-text-conditional-6681 ↩
-
https://docs.oracle.com/en/database/oracle/apex/24.1/htmdb/about-using-substitution-strings.html#GUID-C47D5D9B-3476-48EA-A0B1-DBA96E6E283B ↩
-
https://forums.oracle.com/ords/apexds/post/how-can-i-perform-an-sql-statement-insert-data-into-table-u-4869 ↩
-
https://apex.oracle.com/pls/apex/apex_pm/r/ut/javascript-apis ↩