Im not sure if this is possible or not in Oracle Apex. Essentially what we have is a textbox field on the opportunity form where folks can put in some free form notes about the opp. I'm looking to see if there is a way to have the current date populate into the text field when the user clicks into the field to add some notes.
Please Advise,
Thanks
Suppose item's name is P36_TEXT. Create dynamic action
Event: Mouse button press
selection type: item
item: P36_TEXT
True action:
execute server-side code
language: PL/SQL
code:
:P36_TEXT := to_char(sysdate, 'dd.mm.yyyy hh24:mi:ss');
items to return: P36_TEXT
That's it; run the page. When you click into that item, dynamic action will populate it with current date/time.
Tested on apex.oracle.com, running Apex 20.2.
Related
Is there a good visual tutorial that takes through the various steps on how to create radio buttons in Apex 19.2? This tutorial Creating a Classic Report having radio button on each row helped me and I’m looking for a similar one..
In my case, I would like to add a radio button to each row of my classic report which when selected would add some of the informations selected by the radio button in a text field in the same page.
Any advice is much appreciated.
Thank you
Install Sample Reporting application on your APEX instance (preferably on apex.oracle.com as Dan suggested).
Navigate to the Classic Report page.
Change the query to the report to the following:
select rowid,
ID,
PROJECT,
TASK_NAME,
START_DATE,
END_DATE,
STATUS,
ASSIGNED_TO,
COST,
BUDGET,
apex_item.radiogroup(1,TASK_NAME) ACTION
from EBA_DEMO_IR_PROJECTS
where (nvl(:P3_STATUS,'0') = '0' or :P3_STATUS = status)
Note the added column "ACTION" which consists of the apex_item.radiogroup with TASK_NAME value. Let's assume that this is the value that you want to pass to another page item.
Open that column's attribute under Page Designer and disable "Escape special characters" attribute and add a CSS Class (e.g. mycolumn)
Create a Page Item (e.g. P3_NEW).
Now add the following Dynamic Action
Event > Click
Selection Type > jQuery Selector
jQuery Selector > #classic_report .mycolumn input
Your true action will be of the type Set Value and the Set Type is JavaScript Expression with the following code:
this.triggeringElement.value
Your affected element is P3_NEW and disable Fire on Initialization
I am currently using Oracle Apex version 18.2.0.00.12 on Internet Explorer on a computer running Windows 10.
I am having a problem with downloading an Interactive Grid as a CSV file.
On my Apex page I have an interactive grid and three page items. Two of the page items, P200_DATE_FROM and P200_DATE_TO, are Date Picker items. The other item is a button named "Submit" and its action is "Submit Page".
This is the query for my interactive grid:
select * from kat_test
where repairdate between :P200_DATE_FROM and :P200_DATE_TO;
There are four columns in the Interactive Grid:
Issue - Varchar2
Month - Number
Week - Number
Repairdate - Date
The only settings I changed in the Interactive Grid are the title and the SQL query.
I changed the Source of P200_DATE_FROM to PL/SQL Expression that returns the first day of the current month. It is set to be used "Only when the current value in session state is null". The expression is:
trunc(last_day(sysdate)-1, 'mm')
I changed the Source of P200_DATE_TO PL/SQL Expression that returns the current date. It is also set to be used "Only when the current value in session state is null". The expression is:
sysdate
When I run the page, it loads exactly as expected in the sense that the P200_DATE_FROM page item is populated with the first date of the current month, the P200_DATE_TO item is populated with the current date, and the interactive grid displays the correct data.
The problem: When I select Actions -> Download -> CSV, the CSV file downloads and opens as an Excel file, BUT only the header names are displayed. The cells underneath the headers are all empty. However, if I change one of the dates (or both) in the P200_DATE_FROM page item and/or the P200_DATE_TO page item and then press the submit button, the page is submitted and then when I click Actions -> Download -> CSV, the Excel file opens and all of the data is displayed perfectly (both the column headers and the data underneath the headers).
I don't understand why when I initially load the page, the CSV file for the Interactive Grid does not download correctly, but after I click the submit button the CSV file does download correctly.
Does anyone have any ideas?
Thank you in advance.
I think you just need to put the name of these items in the field "Items to submit" next to your SQL. When it downloads, I think it reprocesses SQL using the values of the items that are in the session. If you do not put those items there, the values do not go to the session. Enter the item names separated by a comma. After that, I think any changes is necessary in your SQL
Report's query, probably, contains a WHERE clause which looks like this:
where some_date between :P200_DATE_FROM and :P200_DATE_TO
Modify it so that includes NVL function whose second parameter reflects items' default values, i.e.
where some_date between nvl(:P200_DATE_FROM, trunc(last_day(sysdate)-1, 'mm'))
and nvl(:P200_DATE_TO, sysdate)
Run the page, download CSV; any improvement?
I have a form that contains a select list (:P10_DROPDOWN) that has its values defined via SQL:
SELECT
display_name,
value_id
FROM
vw_dropdown_options;
As a pre-render-before-header-process I have the following PL/SQL to pre-populate :P10_DROPDOWN:
begin
SELECT value_id
INTO :P10_DROPDOWN
FROM vw_dropdown_option_mapping
WHERE vw_dropdown_option_mapping_id = :P10_DROPDOWN_OPTION_MAPPING_ID;
end;
At this point my form appears on my page, and everything looks okay. However I need to have a custom procedure fire when a user clicks a button, so on a button on my page I defined an onClick event to fire this pl/sql block:
APEX_DEBUG.INFO ('P10_DROPDOWN_OPTION_MAPPING_ID ' || :10_DROPDOWN_OPTION_MAPPING_ID);
APEX_DEBUG.INFO ('P10_DROPDOWN ' || :P10_DROPDOWN);
NP_SAVE_MAPPING_VALUE (
DROPDOWN_OPTION_MAPPING_ID => :P10_DROPDOWN_OPTION_MAPPING_ID,
NEW_DROPDOWN_VALUE_ID => :P10_DROPDOWN
);
This is where I first notice my issue; the value logged out by the onClick for :P10_DROPDOWN is what was originally set via my pre-render-before-header-process, and not the value I select via my drop-down.
I have tried setting the source.used value on my dropdown to both "Always" and "Only". I have also replaced my pre-render-before-header-process with a source based single value SQL query. Neither is allowing my dropdown to change the session value via the dropdown.
Am I missing something about these session values?
I suspect that this is because newly selected value isn't in session state. To test it, create a SUBMIT button, push it, and then check the result again.
Just asking: did you consider
setting item's default value (instead of writing a process to pre-populate it)
using a dynamic action (instead of creating an onClick event)
I need to implement a simple product form from a block of data called "PRODUCTS".
The products are related to a "Partner" through the field "COMPANIES_PARTNERS_ID".
This field will be represented by an LOV to select the Partner for which we want to visualize your products.
If there is not a partner currently selected, all your products should be displayed. And when a partner is selected, only their products should be displayed.
The form will look like this:
The button to the right of the search field should show the LOV and launch the query. I tried the following code as a "Smart Trigger" when I pressed the button. But it does not work well at all. The LOV list appears twice and when no partner is selected, no product appears.
Could someone help me to implement this functionality? Thank you
You don't need to use ENTER_QUERY command.
had better using DEFAULT_WHERE set with respect to COMPANIES_PARTNERS_ID. If not selected any of the rows of LOV by pressing CANCEL or dissmissing by X sign, then all of the products will be listed(In this case you'll see the first ID, most probably with value 1, since COMPANIES_PARTNERS_ID is not located at a CONTROL block but at the same block,namely PRODUCTS, with other items. As you go down by down-arrow you'll see the other ID values when your cursor is in COMPANIES_PARTNERS_ID field, seems that Number Of Items Displayed is set to 1 for this field, because PRODUCTS block has been set as 10 items displayed ).
So, you may use the following code in WHEN-BUTTON-PRESSED trigger :
DECLARE
V_WHERE VARCHAR2(500);
BEGIN
GO_ITEM('COMPANIES_PARTNERS_ID');
IF SHOW_LOV('COMPANIES_LOV') THEN
V_WHERE:='COMPANIES_PARTNERS_ID='||:COMPANIES_PARTNERS_ID;
ELSE
V_WHERE:='1=1';
END IF;
SET_BLOCK_PROPERTY('PRODUCTS',DEFAULT_WHERE,V_WHERE);
CLEAR_BLOCK(NO_VALIDATE);
EXECUTE_QUERY;
END;
Once you enter query mode (which is what ENTER_QUERY does), further processing is stopped until you execute query.
I presume that you created a LoV properly - the most usual way is to create a Record Group query first, and then create a LoV based on it.
Therefore, I'd ENTER_QUERY in WHEN-NEW-FORM-INSTANCE trigger and let your current push button display LoV and let user select a value into the "Companies Partners ID" item. Executing a query (either by pressing the corresponding toolbar button, shortcut key (F8?) or your new "Execute query" button) would then actually execute query. If master-detail relationship is properly created (using the Data Block wizard is the simplest option), then you'd get rows in the "Products" block.
Put a value in PRODUCTS block WHERE clause' property.
WHERE CLAUSE property:
COMPANIES_PARTNERS_ID LIKE NVL(:lov_block.COMPANIES_PARTNERS_ID, '%')
I'm creating a form in apex where I want to populate a text box with a value which has been selected in a drop down box. This needs to be done using a select statement on the form.
I have tried using a Dynamic action.
If I was using SQL I would pass the value of the id which I have retrieved using a combo box.
SELECT APPLICATION_ID FROM APPLICATIONS WHERE JOBID = :P55_JOBID
this would update my APEX field (P55_APP_ID)
P55_JOBID is the Job ID APEX field.
The Select statement for APP_ID works but I want it to be updated when the Job Dropdown list changes. I've been told to use a Dynamic action but I cant work out how it triggers a refresh of App_ID..
thanks for your help,
mike
Thanks for your help.
You want a dynamic action that is triggered on the Change event of the select list (P55_JOBID). The action of this will be Set Value and the Set Type will be SQL Statement. Add your SQL (SELECT APPLICATION_ID FROM APPLICATIONS WHERE JOBID = :P55_JOBID) here and then under Page Items to Submit include your select list (P55_JOBID).
The Selection Type will be Item(s) and the Item(s) will be your text area (P55_APP_ID).