"general" variable in oracle apex - oracle-apex

I'm developing an application in Oracle Application Express (APEX).
First page contains list of projects as a tabular report.
Clicking any of the rows forwards to the next page, where records can be edited. I've implemented it with following settings:
Link column: link to custom target
Target: Page in this application
Until this is fine.
My problem is how to pass actual report to the next page?
My table, which is the basis of the report has primary key (ID), and also owner & title combination is unique. Currently ID column is not included in the report.
Also the second page doesn't currently contain field showing ID, as this information isn't important to the users.
I know I could set ID column in report, and create a read only (even hidden) text box in the next page, however I'm looking for a more elegant solution. What is the standard way to solve this?

I wonder if you are asking: "How do I pass a value from page 1 to page 2 so page 2 can use the value to do a query and present the results. If so, here is how it's done.
On page P1, the report, for example, select the attributes for the report region under the region in the Rendering pane on the left of the page designed.
Under Attribute Properties on the right side, look for Link Column and set it to "Link to custom target". Then click Target.
Select the page and then in the Set Items section, on the left, under name, select the PK ID field to receive the passed value ex: P2_ID. On the right under Value select the field to pass the value, ex: #P1_ID# and click ok.
Now, when the link on page 1 report is clicked, the P1_ID is saved into Session state by Apex and passed to P2 which then performs a FETCH using the passed value.
You can read more about Session State here. Also, be aware there are security settings which affect what params can and can't be passed in the URL.
Clicking "Session" in the developer toolbar will enable you to see the session variables being passed.
If you mean "How do I store values in the app that can be accessed anywhere in the app - like a global variable" Then look at Application Items.
As always, please include version numbers in these posts.

When you create a target page let's say Page 3
And you create some items, let's say P3_ITEM_1,P3_ITEM_2, etc
You can assign values to each of them through the url in the original page
The complete APEX URL Syntax looks like this:
http://apex.oracle.com/pls/apex/f?p=AppId:PageId:Session:Request:Debug:ClearCache:Params:ParamValues:PrinterFriendly
Let’s take a closer look:
http:// – the protocol, can be http or https
apex.oracle.com – your domain/host/server, whatever you want to call it. Can also be localhost.
/pls – indicates that you are using Oracle HTTP Server with mod_plsql. If you are using APEX Listener or Embedded PL/SQL Gateway this part is obsolete/missing.
/apex – the entry from your dads.conf file (this a file on your application-server or EPG where the target database is configured) – in case of EPG its just one entry pointing to localhost, in case of an OAS you can have multiple entries, each pointing to an other database
/f?p= – procedure “f” is called and parameter “p” is set to the complete rest of the string. Remember: APEX uses mod_plsql. “f” is a public procedure, this is the main entrypoint for APEX. Or you could say: “f” is APEX.
AppId – the number or the Alias of the Application
:PageId – the number or the Alias of the Page
:Session – unique Session ID, can be 0 for Public Pages or empty (then APEX creates a new Session)
:Request – a Request Keyword. This is basically free text, just a string you can specify to react in a process or region condition on. e.g. you could pass the keyword “CREATE” and have a condition on the delete button of your page saying “dont’t display this button if request is CREATE”.
In other words: use the REQUEST to control the behaviour of your page.
When pressing a button, the button sets the REQUEST to the button-value (e.g. SAVE), so that you can control the processes in the page processing (Submit) phase.
:Debug – set to YES (uppercase!) switches on the Debug-Mode which renders debug-messages and timestamps in your Browser window. This helps to detect wrong behaviour of your page or performance issues and everything else. Every other value then YES turns the Debug-Mode off
:ClearCache – you can put a page id or a list of page ids here (comma-separated) to clear the cache for these pages (set session state to null, …). But there is more: RP resets the pagination of reports on the page(s), a collection name deletes the collection, APP clears all pages and application-items, SESSION does the same as APP but for all applications the session-id has been used in.
:Parameters – comma seperated list of page-item names. Good practice is to set only those page-items which are on the page you are going to. Accepts page-items as well as application-items.
:ParamValues – comma separated list of values. Each value is assigned to the corresponding Parameter provided in ParamNameList (first value assigned to first parameter, second value assigned to second parameter, and so on…).
The trick here is not having values which contain either a comma “,” or a colon “:”. Both would lead to side-effects and errors, as APEX gets confused when parsing the URL. Using a comma works, if enclosed by slashes: e.g. \123,89.
:PrinterFriendly – set to YES (uppercase!) switches the page into PrinterFriendly-Mode, uses the Printerfriendly template to render the Page. You can also hide regions or other elements in PrinterFriendly-Mode using the PRINTER_FRIENDLY variable in a condition.
In your case you'd use Params:ParamValues like this:
P3_ITEM_1,P3_ITEM_2:someValue_1,someValue_2
Documentation

Related

Pass values between pages Oracle APEX

There is a problem transferring values between pages in the application. I have 2 pages on the first page there is a variable P9_ITEMID (when you run page 9, in this variable SQL Statement query writes the data). There is a second page 181. I want to move data from variable P9_ITEMID to variable P181_ITEM. To do this, I use the 'redirect to page in this application' option. But it doesn't work. Although I see in the variable P9_ITEMID there is data. But when you go to page 181 but P181_ITEM is empty. I would be grateful for help))
P9_ITEMID is a virtual variable that is not assigned to any column in the table. This mmin simply displays data. When I start the page, I see the data that was written to it due to the dynamic action
also i tried to write the value in P9 ITEMID this way
My code:
declare
v_empname items.id%type;
begin
select id into v_empname
from items where id = :P9_ITEMID;
apex_util.set_session_state('P9_ITEM_ID', v_empname);
exception
when others then
apex_util.set_session_state('P9_ITEM_ID', null);
end;
I'm assuming that you have created a button with action: 'redirect to page in this application' and you want the session value of a page item to be passed to the target page.
When an url is constructed using link builder, the link is built at page rendering time. It does not pick up any changes in session. Even when you set the session state in a dynamic action, it will not pick it up because the url is already rendered.
To pick up any changes on that page, it is necessary that the page item value is set in session state and this is done by the "page processing".So if you use "Submit Page" on the button and create a branch to redirect to the page it will behave the way you want.

Oracle Apex dynamic action not firing on true condition

I have a page with two Interactive Grids. One shows Approved records. One shows Unapproved records. There is a button with processing underneath on each grid to set the selected rows to Approved/Unapproved respectively.
I want to hide these buttons based on if a user is an Approver. These values are store in some user managed tables.
I have a dynamic action on Page Load that runs the following and sets a page item to 1 / null depending on the return:
select 1 from users where upper(username) = upper(:APP_USER) and userrole = 'APPROVER';
Based on the value in the page item two dynamic actions fire on page load to set the buttons with
True=Show
False=Hide.
Client Side Condition: Item = Value: P1_PAGE_ITEM = 1
Now - on my local machine this works fine. I made the page item visible. Can see a 1 or null and the buttons are hidden/shown.
I moved this to a Development environment and now I get a warning about Unsaved Changes each time I click out of the page (doesn't happen on Local). And although I can see a 1 in the Page Item field the actions see this as False (I put an alert on to fire when true/false).
Question is: Why am I getting the unsaved changes warning on the new environment. And why would the actions see the field as FAlse.
I have compared all of the properties as best as I can and they seem identical. I have even arranged the sequence numbers to be identical in the two environments.
All thoughts welcome...
This doesn't need to be a DA that is modifying a field value, hence the alert.
Why not define a computation that executes during the render, and use that as a server side condition on your Dynamic Action?
Otherwise you've enabled a security threat, where the user can tweak some HTML to see the regions you've hidden.

Oracle APEX - Reusable Pages?

We have some tables in our database that all have the same attributes but the table is named differently for each. I'm not sure of the Architect's original intent in creating them in this way, but this is what I have to work with.
My question for all the expert Oracle APEX developers: is there away to create a reusable page that I can pass the table name to and that table name would be used in the reporting region and DML processing of that page?
I've read up on templates and plugins and don't see a path forward with those options. Of course, I'm new to webdevelopment, so forgive my ignorance.
We are using version 18.2.
Thanks,
Brian
For reporting purposes, you could use a source which is a function that returns a query (i.e. a SELECT statement). Doing so, you'd dynamically decide which table to select from.
However, DML isn't that simple. Instead of default row processing, you should write your own process(es) so that you'd insert/update/delete rows in the right table. I've never done that, but I'd say that it is possible. Basically, you'd keep all logic in the database (for example, a package) and call those procedures from your Apex application.
You could have multiple regions on one page; one region per table. Then use dynamic actions to show/hide the regions and run the select query based on a table name selected by the user.
Select table name from a dropdown or list
Show the region that matches the table name (dynamic action)
Hide the any other regions that are visible (dynamic action)
Refresh the selected region so the data loads (dynamic action)
If that idea works let me know and I can provide a bit more guidance.
I never tried it with reports, but would it work to put all three reports in a single page, and set them via an Item to have Server-Side Conditions that decide what gets shown in the page? You'd likely need separate items with a determined value for the page to recognize and display.
I know I did that to set buttons such as Delete, Save and Create dynamically, rather than creating two or more separate pages for handling editing of certain information. In this case it regarded which buttons to shown based on a reports' primary key being sent to said "Edit" page. If the value was empty, it meant you wanted to create a new record (also because the create button/link sent no PK). If said PK was sent (via a edit button/link), then you'd have the page recognize it and hide the create button and rather show the edit button.

Oracle APEX - Transferring page item value from one page to another

Not sure what am I doing wrong and need help to diagnose the issue.
I have an apex page with an IG on it with radiobutton selection column, allowing the user to select only one row at a time.
On row select I use javascript to grab the ID of the selected row and then use Execute PL/SQL
NULL;
in order to store the value into the session state of P2_ID.
I also have a button on the page that has another page as a target - page 3, and I need to get my P2_ID value to that page.
So I set the page item of a target page - P3_ID ro &P2_ID. in a Link Builder - target pop up window. Along with that I pass another page item P2_TEST, which has a static value.
Now when I get to page 3, I do not see P3_ID in the session state while I do see P3_TEST and it does have a value, but P3_ID is not even listed... What am I doing wrong here?
How about this: instead of executing NULL; when pushing the button, SUBMIT (submit will certainly store values into session state). Create a branch which takes you to page 3; among branch properties, you'll find an option to set P3_ID to P2_ID

Oracle APEX - the value does not carry over when using Redirect to Page

I have a field on my page that I want to carry over to another page in the application.
On a button click I use "Redirect to Page in application" and set the page number to 2.
Now I want to carry over the value P1_MY_ID to page 2, so I used Set Items for target page:
NAME VALUE
_________ _______
P2_RECORD_ID &P1_MY_ID.
On Page 2, P2_RECORD_ID is a Select List filled from a shared LOV and its source is set to a database column.
Once page 2 opens, I do not see the value P2_RECORD_ID in a session state.
Am I doing something wrong?
Typically if an item has Source Type = Database Column, the Source Used will be "Always, replacing any existing value in session state". This means that on page load the item's value will be overwritten by the Automatic Row Fetch process.
In your particular case, it seems the value you are passing is the record ID - if this is a unique identifier for a record to retrieve from the database, you need to check that it has been set as the Primary Key Item in the automatic row fetch process.
Interesting but I just switch places for the items I am passing and it worked... Not sure why it worked but I'll take that...