cross-conditional color formatting based on user input in Oracle Apex - oracle

I am currently trying to add a feature to an existing Oracle Apex application (Apex). I have already looked around on here and found a few guides but none are helping me specifically with this subject and as I am a complete newbie to Oracle Apex, I am asking this question and thankful for any help:
how can I cross-conditionally color format the text of a text-field returned to the user (see link below) based on another item on the page? More or less like a succes/failure-message.
highlighted succes/failure-message-text
The content from the success/failure-message is returned from a stored procedure, which is run after the user scans a barcode for input (:P1_CANN, text field, label: 'Scanneingabe'). After running, the stored procedure returns two values: the content of the success/failure-message (:P1_CANNBACK, display only page item) and a value 1/0 for scan/failure of the scan (:P1_CSS,hidden page item). Based on the value returned from :P1_CSS I would like to color the text of the success/failure-message correspondingly, for instance to green if the returned value is 1 and red if it is 0.
I am using Oracle 12c as the database. The stored procedure runs a short PL/SQL-Code:
*#OWNER#.DOMENICO_SCANN_ENT(PSCANN => :P1_CANN, pr => :P1_CANNBACK, pr1 => :P1_CSS);*.

This can be achieved using css. There are different ways you can implement this. One way is this:
Create a page item to contain the class name, eg P1_CANNBACK_CLASS
Create a computation to set the value of P1_CANNBACK_CLASS after you have called your stored procedure. PL/SQL code would be something like
CASE :P1_CANN WHEN 1 THEN 'u-success-text' WHEN 0 THEN 'u-danger-text' END
On Page Item P1_CANNBACK, set the css class to &P1_CANNBACK_CLASS.
Note that I used the apex provided css classes (documented here: https://apex.oracle.com/pls/apex/apex_pm/r/ut/color-and-status-modifiers). You can use your style, but then you'll have to define the css classes in the page properties or in a static file. I tested this on a 20.2 instance.

Related

Referencing fields in BI Publisher RTF template conditional regions

I'm putting together a report in the BI Publisher Word .rtf plugin with very specific layout needs. One of those needs is the ability to switch company logos depending on parameters entered. I've been using conditional fields to selectively display each logo, but for some reason I can't reference data fields in the conditional code.
I've used these methods:
<?if: column_name = 'desired_value'?> [logo1] <?end if?>
<?choose:?><when: column_name = 'desired_value'?> [logo1] <?end when?>
Both of these methods seem to work when given raw values (i.e. instead of column_name = desired_value, I used 1=1 and it printed) but not when I use the name of the column I'm trying to compare.
For a more concrete example:
<?if: p_jno_in > 0?>
is always false, as if p_jno_in is null rather than having a value. (this variable represents the job number of the report and will never be null, even in my test data/sample xml.)
EDIT: Here is an example of what I've used, and the output.
If you host the image on the server, you can do all sorts of stuff with BI Publisher logic and concatenating an image path string. Make sure you or your DBA makes the path readable by BI Publisher. They can also map it to an FTP connection so you can edit/add images without being in Unix.
Insert any dummy placeholder image in RTF template (Insert Picture)
Right click on image and click “Edit Alt Text” and enter dynamic path. (See below for example)
url:{concat('${OA_MEDIA}/XX_LOGOS',/XML_PATH/LOGO_NAME,'_','small','.jpg')}
Other older versions of Word may have this data stored in the Size/AltText or Format Picture/Web menus
I looked around a bit and found the answer to my question. Turns out I was actually using the correct format the whole time! The issue was actually that I was referencing fields inside a for-each grouping, which I think might limit the scope. So, for example, if my BI Publisher data model has a query block A that has been split into two groups AA and AB, trying to reference a field from AA when you're in a for-each looping on an element from AB will not work.

How to access individual cells of interactive grid in APEX?

I am working on an APEX application where i basically need to make some particular cells of a column read-only based on some condition during the page load. Lets say a column accepting date values. I tried using the ReadOnly attribute to do so by using the PL/SQL expression and PL/SQL function body as the options but i am not clear of the format it expects me to use. Is it possible to do it this way? If yes, then how should i proceed with it?
I also saw a way to access the cells independently through Javascript and iterate on the cells later using this...
var view$ = apex.region("----").widget().interactiveGrid("getViews").grid.view$;
where "----" is the region id. How can i find my region id if this could be one possible solution?
To make the region ID predictable, set a Static ID in the region properties.

How can you properly automatically set which interactive report you navigate to in oracle apex?

I am using oracle apex 4.2 and was wondering if there is a special way to link to a certain default report that I created. So for example below I have made Region Name Pie report along with the default. I changed the aliases to 1 and 2 respectively. I tried using the link example but the synatx is malformed, so I tried another option below.
Here, I tried to set the Report ID Item to a variable that I set as I move to this page. And I looked at the session and this value is being set to 1 as needed(I assumed it was the Report alias I needed to set the value to).
Are these methods viable in Oracle or am I doing anything that is noticeably wrong? Thanks.
Edit: Error for Syntax:

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