I have the following select statement but unsure how to setup the dynamic action to assign the current sysdate when the user select
an option from with the LOV. I basically want to populate automatically the “DATE_CALLED” field to sysdate when a LOV selection is
made via a Dynamic Action.
Trying to use the same processing from this thread that was against a checkbox but cannot seem to work out – see:
Oracle ApEx Checkbox to Manipulate Other Values When Checked/Unchecked
select APEX_ITEM.HIDDEN(1,change_id) ||
APEX_ITEM.HIDDEN(2,contact_id) ||
APEX_ITEM.SELECT_LIST_FROM_LOV(p_idx => 10,
p_value => reason_id,
p_lov => 'LOV_REASONS',
p_attributes => 'class="lov_select"',
p_show_null => 'YES',
p_null_value => NULL,
p_null_text => '--- Please select a reason ---') reas,
APEX_ITEM.TEXT(p_idx => 20,
p_value => TO_CHAR(date_contacted,'DD/MM/YYYY HH24:MI'),
p_size => 14,
p_attributes => 'class="date_val" readonly="readonly" style="background-color:#B0C4DE;border:1px solid #999999;"') "DATE_CALLED",
APEX_ITEM.TEXTAREA(p_idx => 30,
p_value => comments,
p_rows => 2,
p_cols => 30 ) "MPA_COMMENT"
from MY_TABLE
For the Dymanic Action, I have the following:
Dynamic action: "lov selection"
Event: Change
Selection Type: jQuery Selector
jQuery Selector: .lov_select (this is the class I added to the select list from lov in the sql)
Condition: JavaScript Expression
Value: ****** Unsure what I need to put here ******
For True Action, I have the following:
True Action:
Sequence: 10
Action: Execute PL/SQl Code
Fire On Page Load: No
Code: :P1_DEF_DATE := TO_CHAR(SYSDATE,'DD/MM/YYYY HH24:MI'); and have Page Item Submitted and Returned
Sequence: 20
Action: Execute JavaScript Code
Fire On Page Load: No
Code: $(this.triggeringElement).closest("tr").find("td[headers='DATE_CALLED'] input").val($v('P1_DEF_DATE'));
This code is not working as $(this.triggeringElement) is not correct for a select list.
How can I achieve what I need based on a select_list_from_lov scenario and not a checkbox?
I used the condition on the checkbox to distinguish between the checked/unchecked state, and to be able to define both true and false actions. You don’t really need this on the checkbox: change will fire whenever the value changes (ie: user selects another option).
However, if you want to catch an invalid/null option you could use the condition, but instead of javascript expression use one of the operators to test the value (eg: “=” with “1”)
To further elaborate on the action on your select list:
this is the query i used to set up an example:
I used an lov with static values for
LOV_REASONS.Code in True action:
This seems to work fine for me.