Oracle Apex passing item value - oracle-apex

I have an Item select list Workspace value (a,b,c) in page 1
I am selecting some value ex:'a' in item page 1 and stored that in table.
Now I want to display the selected value in page 1 to should display as default item value of another item in another page 2 as default value.
Is this is possible please let me know how to proceed.

The default value for an item can be taken from another item by setting the Default Type to PL/SQL Expression. You can refer to another item on the page using bind variable syntax, e.g. :P2_WORKSPACE.
In the navigation from page 1 to page 2, you would need to copy P1_WORKSPACE into P2_WORKSPACE (this is preferable to referring directly to the page 1 item).

Related

Oracle APEX - automatically select a single item in a cascading popup LOV

I have two cascading popup LOVs on my page P2_LOV1 and P2_LOV2
P2_LOV2 gets populated based on a query and the value selected in P2_LOV1. What I want is if there is only one value populated in P2_LOV2, set it as a selected value. How can I do that?
You could create an on change dynamic action with a client side condition of
$('#P2_LOV2 option').length == 2
The length may be 1 or 2, depending on if you have a null option.
If true, set the value. Again, the numeric may be 1 or 0, depending on null selection.
('#P2_LOV2').prop('selectedIndex', 1)
But if you don't have a null selection, this would automatically set to first value, right?

Oracle Apex: Auto select if shuttle list contains only a single item

I have a shuttle list that, depending on the selection of a previous form, may have between one and seven items. Is there any way for me to automatically move the entry to the right hand pane if there is only a single selection, just for the sake of long term optimization and user friendliness?
You can add a default Value to your shuttle item
SELECT YOUR_COLUMN_ID
FROM T0000_YOUR_TABLE
WHERE FILTER_COLUMN_ID = :P_FILTER_ITEM_PREV_FORM
GROUP BY YOUR_COLUMN_ID
HAVING COUNT(*) = 1
If there are more than 1 entries for your filter item the statement will return nothing, if there is exactly 1 entry the entry will be returned and set for your shuttle item
I like sim0n's answer. But here's another that uses JavaScript (you can choose which is best for your use case).
Create a Dynamic Action. Set Name to Page loaded and Event to Page Load.
Select the Action created by default. Set Action to Execute JavaScript Code, then enter the following code in Code.
var itemId = 'P1_ITEM_NAME';
var $opts = $('#' + itemId + ' select:eq(0) > option');
if ($opts.length === 1) {
$s(itemId, $opts.val());
}
Don't forget to change the name of the item to match the one on your page.
When the page loads, the JavaScript will check to see how many options are in the select element on the left. If there's just one, it will set the value of the item using the value to the value of the single option.

How can I pass a value from one page so that my "Row text contains" filter is enabled in Oracle APEX

Is there any way in Oracle APEX where we can pass a value from one page to other page, and in the other page it emulates the filter same as "Row text contains".
For eg:
Page A ---> clicks on a link to call Page B and Passes a value '12345' to this new page.
And then
Page B opens up with all the values where row text contains '12345'
I have created a hidden field 'P17812_EMPLOYEE_NUMBER' on page B.
When I click on a link on Page A, I set the value in this field.
Now, I created a dynamic action on "page load" on page B. Where i write the below code :
$("#apexir_SEARCH").val($v("P17812_EMPLOYEE_NUMBER"));
gReport.search("SEARCH");
But this also doesn't work.
Is there any way we can implement this scenario?
Thanks for your help.
You can use IR_ROWFILTER in URL as a parameter and in parameter values the value that you want to filter like:
?p=App:Page:Session:Request:Debug:ClearCache:IR_ROWFILTER:12345:PrinterFriendly
You can read more about APEX url in here https://docs.oracle.com/database/121/HTMDB/concept_url.htm#HTMDB03019
and about IR filter https://docs.oracle.com/database/apex-5.1/HTMDB/linking-to-interactive-reports.htm
Create a hidden page item on page B, have the link set value to the item when you click on it
then have the same select statement from page A on B with a where clause
SELECT a, b, c
FROM test
...
WHERE b = %ITEM%
(THE % tells him that it can be whatever text or no text there)
and dont forget to pass the item to the sql query
I hope I understood what you want, and that my answer is understandable.

How to pass data between fields in Oracle APEX 5.1?

This is a VERY basic question. Sorry for not providing any code I have NO IDEA how to even start tackling the problem
I have lets say two fields... One is a date selector field and the other a regular text field. What I want is when I select a date (or type a date), the value comes in the second field... Just that...
I'm on APEX 5.1.4
Since you have stated that the second item is a text field, you could do this with the help of a dynamic action that sets the value of the second item when there is a change in the value of the first item ( date field).
The following would be the steps, if you are using component view:
Create Dynamic Action
When
Event : Change
Selection : Item(s)
Item : First Page Item
Condition : is not null
True Action
Action : Set Value
Fire on Page Load: No
Set Type: You can choose how you want to set the value of the second item on the page.
If you have the flexibility to change the second item to be a select list and you have a list of values that goes with a date, you could do this much simpler, with a Cascading LOV
On Second Item's - Under List of Values section
Cascading LOV Parent Item(s) : First Item
Page Items to Submit: First Item
List of Values definition: Here you can define the query.
Hope this helps.
There are a few different ways to do this, probably the easiest way is as follows.
Assume your two items are P1_ITEM1 and P1_ITEM2.
Create a dynamic action which fires on change of item P1_ITEM1.
The true action of this should be action:set value, set type:PL/SQL Expression, item::P1_ITEM2, items to submit P1_ITEM1.

Get value from list item and assign to an application item

I am new to APEX and I tried to assign a value from a list_item (based on a query with displayed value and return value) to an application item, and it doesn't work.
When I assign the value statically, it works:
:F1010010_RESP_ID :=111;
But how can I assign the value dynamically?
Greetz
Tim
If you have a drop-down list control on a page named, say, P1_MY_DROP_DOWN, then :P1_MY_DROP_DOWN will have the value that is currently selected. Normally, you'd just reference that page item. If you want to assign it to an application item, though, you'd just do the assignment
:F1010010_RESP_ID := :P1_MY_DROP_DOWN;