Oracle Apex 5.1 (How to add custom link additional to default link on Interactive report) - oracle

How to add additional custom link to modal dialogue page from Interactive report in Oracle Apex 5.1
I want to show this link only when flag is Y for specific rows.
What will be the best way to do it...

Create a link (using f?p syntax) as a column in report. As you only want to display it when some condition is met, use CASE (or DECODE), e.g.
select
id,
name,
--
case when flag = 'Y' then 'f?p=&APP_ID.:3:'||&SESSION.||'::NO::P3_POG:4005
else null
end as link,
--
etc.
from your_table
where ...
In this example, I'm calling page #3 and passing 4005 to P3_POG item value.
A better option (as Jeffrey suggested) would be
case when flag = 'Y' then
apex_page.get_url(p_page=>3, p_items=>'P3_POG', p_values=>my_id)
end as link
Don't forget to set escaping special characters property for the LINK column.

Related

Clear Page Item in Oracle Apex

I am calling an IR with a link using a hidden page item to filter the IR records. The IR has a search region as well. Now when I click the link, the IR report opens with desired records.
Now as IR is already open and when I try to use the search region LOV to see other records it always shows me records with the previous page item hidden column even though I am changing the LOV.
how can I fix it?
IR query is as below:
(SELECT email_address, status, description FROM recipients
WHERE recipient_group_id = NVL ( :P6_$RECIPIENT_GROUP_ID, recipient_group_id )
AND recipient_id = NVL ( :p8_recipient_id, recipient_id ))
The :P6_$RECIPIENT_GROUP_ID is coming from the previous page from where I am calling the IR using the link column.
The p8_recipient_id is the value coming from the search region of IR.
That is expected behaviour. The page item value for :P6_$RECIPIENT_GROUP_ID will be set until it is reset, either by setting the value to NULL or clearing the cache on page 6 (I'm assuming that is where this page item is defined).
If you want to clear the value of P6_$RECIPIENT_GROUP_ID then define a dynamic action on change of P8_RECIPIENT_ID to set P6_$RECIPIENT_GROUP_ID to NULL. Make sure the interactive report has attribute "items to submit" including both P6_$RECIPIENT_GROUP_ID and P8_RECIPIENT_ID.
Note: referencing a page item from another page is not a good practice. It may lead to unexpected results. A cleaner solution would be to define a P6_$RECIPIENT_GROUP_ID on page 8 and set that from the link to the IR.

i've created a interactive report in oracle apex and i want to connect different links to different rows of the same column

this is my oracle apex report page i'm having a problem in. It has a interactive report which has 2 columns but both the rows of the same column refer to the same page in the application or for the matter to same url. i want to give different link to different rows of the same column.
You'll have to create links manually for each row. For example (taken from one of my IRs):
SELECT
'f?p=&APP_ID.:' || case when r.id_obr = 6 then 217
when r.id_obr = 7 then 221
end ||
':&APP_SESSION.::NO::' || case when r.id_obr = 6 then 'P217_ID_OBR6'
when r.id_obr = 7 then 'P221_ID_OBR7'
end ||
':' || r.id_obr67
as link, ...
Created in such a way, it'll take you wherever you want, passing any values you want to any page you want.
We dont know what version of apex you are on, but I will just give you the answer that works for me.
Create the links on each column and then create hidden page items on the page you are linking to, then using the links, have them set a value to those page items based on what was clicked.
Then you can just use those page items in your SQL query on the page you are linking to.
Or you could even use those items to create filters, but those a pain in the ass to set up, so I would suggest adding the items to your query for simplicity.

How to make select list and input text field read only for preventing editing

I am developing an oracle APEX application.
I created the form with master details form. How to make select list and input field to read only on tabular form (Add Row Section) when the status value is selected "Closed" or "Cancelled".
I have searched on stackoverflow but I could not find any related question about that.
Please give me idea about that ? Thank you..
Add a classic report to the page with the same columns. Render the tabular form when the status is not close or cancelled, and render the classic report when it is by using the condition on both regions.
Probably half a dozen ways to do this.
Add column in your sql (that isn't displayed to user) that calculates literal value of 'readonly' or null, depending on your status column value. Give it a column alias of 'readonly'
CASE status IN ('Closed','Cancelled') THEN 'readonly' END AS readonly_col
Edit your Status column and add to 'Element CSS Classes' : #READONLY_COL#
(hash tag surrounding your column alias)
For LOV/Select List, here is a simple solution for you
// disable:
$('#P123_ITEM_CNT').attr('readonly', true);
$('#P123_ITEM_CNT').css('pointer-events','none');
$('#P123_ITEM_CNT').css('opacity','.5');
$('#P123_ITEM_CNT').off('keydown');
//enable:
$('#P123_ITEM_CNT').attr('readonly', false);
$('#P123_ITEM_CNT').css('pointer-events','');
$('#P123_ITEM_CNT').css('opacity','inherit');
$("#P123_ITEM_CNT").on('keydown');

Change page title based on item in Oracle APEX 4.0

In Oracle APEX 4.0, I have a database of customers and I would like the page title to change to the name of the customer I selected to edit. I entered the title like this:
http://i.stack.imgur.com/Bo0cy.png
However, the tab comes out like this:
http://i.stack.imgur.com/Z41H4.jpg
What am I doing incorrectly?
Using a Substitution String to Set Variable Apex Page Properties
This solution was developed on a system hosted by Oracle Corp. at apex.oracle.com, where the APEX (Oracle Application Express) version is currently 4.2.5. Although the OP is requesting advice for release 4.0, the functionality requested has been possible since the late 3.x versions of Apex through to the present.
This solution uses substitution strings. Any application item or page item can be referenced by a substitution string. Any string that begins with an ampersand (&), ends with a dot (.), and contains an item's name (in all capital letters) between them will be interpreted as a substitution string and will be replaced by the item's value in the current session/context.
This is useful because the value of the referenced item can be manipulated through PL/SQL code, SQL queries, and user input.
Substitution String Notation:
You can refer to a page item PX_SAMPLE_ITEM with the substitution string
&PX_SAMPLE_ITEM..
It is important to note that the dot at the end is necessary.
Setting a Variable Page Title
This is one place where a variable application ITEM can be set (Page Title Attribute):
The following are a couple of screenshots where I used a page-level item, defined as a variable SELECT LIST form element. The select list item also had a REDIRECT property set so that the page would automatically refresh and update the page title property each time a new value was selected or altered.
Verifying Page Configuration and Settings
If you have any difficulty getting things to work from the first pass when creating the page and its contents, this a summary of the settings to verify:
Note that within the view of the application, PAGE 11 is the page which contains my example of a variable page title value.
Drill down to the layout properties of page 11. P11_PAGE_TITLE is the bucket that contains whatever you want the page title to be. This can be a static definition, the result of a user selection, etc. Make sure to create this item and use the same name when referencing it within your page title definition section (highlighted in section/step 3 below)
Note the circled areas. These are the fields that need the definition/reference of the page item mentioned in step 2 above. The first field, the "page name" is not as important as the second field which is part of the "page display" properties. I filled in both, but you probably only need the latter.
Opening the item help-text for the Display Attributes > Title property, the inline documentation says that whatever is inserted into the TITLE field is put inside the <TITLE></TITLE> block of the rendered page HTML code:
An Expanded Discussion on Version Compatibility of this Solution
I cannot speak for sure on the exact version where this approach still works as detailed above. I made a few notes below in response to comments from #MNT, the OP author with respect to keeping their instance and its version of Apex up to date.
No problem #MNT, I mentioned possible compatibility between the method tried in 4.25 (my solution) and 4.00 (your version), but keep in mind, the gap in time between these versions is probably more than two years of upgrades and also a jump between backend databases versions (Oracle 10g to Oracle 11g R1... and even 11g R2) Lots has happened. I suppose that isn't very assuring from your situation, but consider upgrading. All APEX patch and release upgrades are free and it's important to keep up.
Why It's important to keep up your upgrades and patch sets (an example)
The hop from 4.20 to 4.25 alone (from my experience) was an arduous one as actual internal columns were dropped and index keys disappeared... rendering my repository of exported scripts useless. Make sure you leave yourself a back door or a sound upgrade plan (if you have existing applications) for that kind of event. Once you upgrade, there really is no going back :(
declare
l_order_id number;
begin
-- create collections
--
apex_collection.CREATE_OR_TRUNCATE_COLLECTION ('CUST_ORDER_ITEMS');
-- Loop through the ORDER collection and insert rows into the Order Line Item table
for i in 1..apex_application.g_f01.count loop
apex_collection.add_member(
p_collection_name => 'CUST_ORDER_ITEMS',
p_c001 => to_number(apex_application.g_f01(i)), -- product_id
p_c002 => to_number(apex_application.g_f02(i)), -- unit_price
p_c003 => to_number(apex_application.g_f03(i)), -- quantity
p_c004 => apex_application.g_f04(i), -- desc
p_c005 => apex_application.g_f05(i) -- unit
);
end loop;
end;

Passing more than 3 items in a reports column link

I have a report that is listing students and I want a column to edit a student. I've done so by following this answer:
How do you add an edit button to each row in a report in Oracle APEX?
However, I can only seem to pass 3 items and there's no option to add more. I took a screenshot to explain more:
I need to pass 8 values, how can I do that?
Thanks!
Normally, for this you would only pass the Primary Key columns (here looks like #RECORD_NUMBER# only). The page that you send the person to would then load the form based on the primary key lookup only. If multiple users were using this application, you would want the edit form to always retrieve the current values of the database, not what happened to be on the screen when a particular person ran a certain report.
Change the Target type to URL.
Apex will format what to already have into a URL text field which magically appears between Tem3 and Page Checksum.
All you need to do is to add your new items and values in the appropriate places in the URL.
I found a workaround, at least it was useful to my scenario.
I have an IR page, query returns 4 columns, lets say: ID, DESCRIPTION, SOME_NUMBER,SOME_NUMBER2.
ID NUMBER(9), DESCRIPTION VARCHAR2(30), SOME_NUMBER NUMBER(1), SOME_NUMBER2 NUMBER(3).
What I did was, to setup items this way:
P11_ITEM1-->#ID#
P11_ITEM2-->#DESCRIPTION#
P11_ITEM3-->#SOME_NUMBER##SOME_NUMBER2#
Previous data have been sent to page 11.
In page 11, all items are display only items.
And P11_ITEM3 actually received two concatenated values.
For example, the calling page has columns SOME_NUMER=4 and SOME_NUMBER2=150
so, in pag1 11, P11_ITEM3 shows 4150
In page 11 I created a Before Footer process (pl/sql expression)
to set up new items, for example P11_N1 as source SUBSTR(P11_ITEM3,1,1)
and item P11_N2 as source SUBSTR(P11_ITEM3,2,3)
So, I had those items with corresponding values from the calling IR page.
The reason I did not pass the primary key only for new lookup access, is because i do not want to stress database performing new queries since all data are already loaded into page items. I've been an oracle DBA for twenty years and I know there is no need to re execute queries if you already have the information somewhere else.
These workarounds are not very useful for a product that bills itself as a RAD tool.
Just include a single quoted word in the select statement (Select col1, 'Randomword', col2 from table 1;)
Then define that column as a link and bingo! More items than 3 to select.

Resources