Oracle apex clear value in select2 plugin with plsql - oracle-apex

I have a Select2 plugin field called :P10_X
I'm trying to clear the field with Pl/SQL in dynamic action
:P10_X := null;
But instead, it inserts the first option of the select list.
when I'm trying any other (valid) value such as :P10_X := 5; it works ok.
The attributes "Display Extra Values" and "Display Null Value" are set to "Yes" so this field can handle null.
Any idea how can I clear this field with PL/SQL? Thanks

Related

Remove value from popup lov once its selected

I'm trying to create lov in which once the machine is started it should not show in popup lov after submit.
Popup lov sql is as below:
select machineid,machinenm from machinemaster where idlemachine = 'Y';
but the issue is once machine is status change and this query not finding result for the perticular machineid so in lov it shows blank.
Please suggest any workaroud.
First of all, query you posted looks wrong. Generally speaking, list of values' query returns two values in the following order:
display value
return value
We usually display names and return IDs, which means that you'd probably want to use
select machinenm as display_value,
machineid as return_value
from machinemaster
where idlemachine = 'Y';
the issue is once machine is status change ...
How is that statement reflected in query you posted? There's no "status" column nor "change" status itself; where clause says where idlemachine = 'Y' - no status, no "change".
... and this query not finding result for the perticular machineid so in lov it shows blank
I believe that you should set the Display extra values property ON. Help says:
An item may have a session state value which does not occur in the given list of values definition. Select whether this list of values displays this extra session state value. If you choose to not display this extra session state value and there is no matching value in the list of values definition, the first value in the list of values is the selected and displayed value.
If you're seeing the NULL value, it means that you actually set
display extra values to OFF
display null value to ON

Display Only vs text fields with "Disabled" attribute set to YES

I am using APEX 21.2.
The help says that "Display Only" Items do not store session state value and text fields with "Disabled" attribute set to yes do. But I tried to create an after header computation and set the value of a display only item and it worked. Is it wrong information or am I missing something?
Disabled
Specify whether this item is disabled, which prevents end users from changing the value.
A disabled text item still displays with the same HTML formatting, unlike an item type of Display Only, which removes the HTML formatting. Disabled text items are part of page source, which enables their session state to be evaluated. Conversely, display only items are not stored in session state.
I tried to create an after header computation and set the value of a display only item and it worked
Why wouldn't it work? It is you (a developer) who set it using a computation (which works), but end user can't modify its value as it is set to be display only so - users can just look at item's value.
A computation before rendering is always possible, that has nothing to do with session state. This is about how the item behaves on page submit.
With the "Display Only" item type you can control its behaviour on submit. Behaviour is the same for "Text Field" items that have the "Disabled" property set to on.
I did a quick test with a form on the EMP sample data set. Create a after header computation of type expression :P1_SAL + 1.
Test 1: Setting "set on page submit" on. The form renders with the salary item increased by 1. When page is saved, the new salary is saved for the record
Test 2: Setting "set on page submit" off. The form renders with the salary item increased by 1. When page is saved, the new salary is NOT saved for the record
Where did you see this help text ? I don't see anything about session state.

Pass column classic report value to PL/SQL

I have page with Classic Report on it (type = PL/SQL Dynamic Content). What I need it's passing one column value to PL/SQL via Dynamic Action when click on another column. It's no problem to initiate click action, but I don't know how to pass equivalent of #col_name# (not :Pxxx_item_name) to PL/SQL.
Application Express 5.0.4.00.12
I'm not sure what you're trying to pass, so I'm just going to call it "item".
In your report add a custom data attribute to the column, data-item="#COL_NAME#". This would go on the image that's getting clicked. You might need to use the HTML Expression option to set this.
Create a hidden item, P1_ITEM and set Value Protected to No.
Create a Dynamic Action that fires when you click the image in the column.
Create a True action on that DA, Action = Set Value, Set Type = Javascript Expression, the JS expression is this.triggeringElement.dataset[ "item" ], Affected Element > Selection Type = Item, Item = P1_ITEM.
Create another True action on that same DA, Action = Execute PL/SQL Code, Items to Submit = P1_ITEM, and whatever code you want in the PL/SQL code section. You can reference P1_ITEM in your code with :P1_ITEM or V('P1_ITEM').
When the DA fires, it will populate the column value into P1_ITEM, then submit that to the server where it's stored in session state, then run your PL/SQL code.

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.

Set value of Popup LOV with dynamic action

I try to set the value of a popup lov with a dynamic action "Set value" of type PL/SQL Function Body. This works with a select list, but not with a popup lov. How can this be done?
Let's assume your item is P1_ITEM and your LOV is
select display, return from table;
In standard Select List value is stored in #P1_ITEM.
In Popup LOV value is stored in #P1_ITEM_HIDDENVALUE, but displayed in #P1_ITEM.
So in dynamic action, you need to set two actions:
Set value 'return' from LOV with affected item P1_ITEM.
Execute JavaScript code
$("#P1_ITEM").val(display)
$('#P1_ITEM').val(&display.)
where display is the name of the field in SQL.
Hope it works.