Remove value from popup lov once its selected - oracle-apex

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

Related

Get Select list Item value in IG report column for DML operation

I have a Select list filter on the top of the page. I want its return value to get into any column which I create in IG report automatic DML process.
Suppose, Select list has a value "Step", when I add a row in IG report, that value should be saved into DB for one column which is hidden on UI.
I tried but sometimes it stores the value which I selected in Select list item as my last selection not the current one. Do I need to create Application item for this? Please help. TIA
In this case there is a table ig_tickes with a status column. On the page there is a page item P131_STATUS (select list) with values "OPEN" and "CLOSED". There is an interactive grid on table ig_tickets with column STATUS hidden. Functionality is that user selects a value from the select list and then clicks "Add Row".
Give the interactive grid a static id of "tickets"
Create a dynamic action on change of P131_STATUS with a true action of type "execute javascript code" and code:
var model = apex.region("tickets").call("getViews").grid.model;
model.getOption("fields").STATUS.defaultValue = apex.item( "P131_STATUS" ).getValue();
That's all there is to it.

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.

How get display value of checkbox in a checkbox group?

I am using APEX 21.1. I have a checkbox group whose list of values is retrieved using a query...
select disease, id from history;
The query returns many checkboxes. I have another textarea item. I need to get the display value for any checkbox whenever it's checked and set item HISTORY to that value. How to do so?
Describing a how-to would be so much easier if you had provided some example page item names and example data. So, lets call your checkbox group P10_CHECKBOX and your textarea P10_TEXT.
Usually, your checkbox group will save the item ids as a colon seperated list, like this: 3:4:5
To display the corresponding display values, make a dynamic action on change on your item P10_CHECKBOX.
Then, use an action of type Execute PL/SQL Code to fetch the display values of your items.
The code could look like this:
select listagg(disease,chr(10)) within group (order by disease) into :P10_TEXT
from history h
join table(apex_string.split_numbers(:P10_CHECKBOX,':')) t on (h.id = t.column_value);
apex_string.split_numbers will convert your colon list into an actual "table" with the column column_value you can use in the join clause. listagg will do the actual concatenation and will work up to a couple thousand characters. chr(10) is an ordinary line break and will have your items be shown line by line, but any other seperator will do.
Last step is to set up P10_CHECKBOX in your Items to submit and P10_TEXT in your Items to return.
Now, whenever you click a checkbox, the textarea will be updated immediately.

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?

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.