Link column in a IG with DA to update a table - oracle

How to create a link column in Interactive Grid to execute dynamic action ?
I created a demo app to delete employee from emp table where I have a DA with 4 steps:
1.Confirmation
2.JavaScript Code
var empNo = $(this.triggeringElement).attr('href');
apex.item('P1_EMPNO').setValue(empNo);
PL/SQL Code
begin
delete from emp
where empno = :P1_EMPNO;
end;
Refresh region
It doesn't work at all, when I click on the link column it does nothing
I created a demo app, I would appreciate any advice:
https://apex.oracle.com/pls/apex/f?p=4550:1
workspace: igtest
user: demouser
pass: apexdemo

Here is one way to do it. This was on my environment, not yours. It is an editable IG report on the emp table, page 55. The functionality is that when a link is clicked the salary is increased by 1.
Short explanation of this technique:
Set the data attribute of link to "EMPNO" so it can be read by javascript
Use a class to capture the click event
Trigger an event when link is clicked
Listen for that event and execute the pl/sql code.
1.
Add a link column to the report. I used the "Create Column" option of the report to add a column of source type "SQL Expression" with sql expression:
'<span class="fa fa-check-circle-o raise_salary" aria-hidden="true" data-empno="'||EMPNO||'"></span>'
2.
Add dynamic action "Raise Salary Clicked", Event scope "dynamic"
Add a true action of type Set Value:
Add a true action of type Execute Javascript Code:
Action: Execute Javascript Code
Code: $.event.trigger("raisesalary");
3.
Add a dynamic action "After raisesalary event", Event scope "dynamic"
Add a true action of type "Execute Server-side Code":
PL/SQL Code: UPDATE emp SET sal = sal + 1 WHERE empno = :P55_EMPNO
Items to submit: P55_EMPNO
Add a true action of type "Refresh" to refresh the interactive grid region.

this.triggeringElement is not working as expected in Oracle Apex after the version 21 as far as I know.
I checked your demo application and saw you are trying to execute Dynamic Action by a Jquery selector. I advise you to use column selector as:
EDIT: When I deeply checked your demo app, I saw that you are using the EMPNO column of type link and setting the link with #EMPNO#.
This means this link is trying to go to the URL: apex.oracle.com/pls/apex//#EMPNO# which is not valid. Either change link URL to a valid modal confirmation dialog page you would create, or remove the link so that dynamic action would be triggered.

Related

Oracle Apex , Current date populate into Text field when user click

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.

Oracle Apex 19.2 - Create Radio Buttons in Classic Report

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

Oracle APEX 5.1 Custom form issue

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)

Oracle APEX How to submit page with PL/SQL insert/update and then transition to next page

I have an Oracle APEX page that collects data via a classic report with apex_item dynamically generated items. Something like this:
select apex_item.radiogroup(qt.save_position, 1, qt.answer, null, null, null, null) col01
from xxpay_360_questions qt
where qt.questionnaire_id = 21
I then save the answers using a submit button that uses "Submit Page" and calls PL/SQL to insert/update the dynamically generated items from above. Something like this:
insert into xxpay_360_answers values (apex_application.g_user, APEX_APPLICATION.G_F01(1));
commit;
My question is how can I also do a transition to the next page of dynamically generated items (since I only have 50 apex variables to play with per page) when the submit button is clicked.
The submit button only has options for "Submit Page" and "Transition to Page" and not "Submit Page and then Transition to Page".
Is there a way of transitioning via PL/SQL as part of the submit code? Or is there an event that can transition after the page has been submitted?
Also how does this work with errors and the nice "Saved" fly over that apex has?
You need to create a Branch, on the after processing region:
Then you need to set as branch point: On Submit After Processing (After Computation, Validation and Processing) and the branch type as: Branch to page
Then specify the page number where your going to:
And finally you can set the branch to be fired only if one particular button is pressed and if one particular condition evaluates to true:
I think that would cover your needs.
But if you want to do it with PL/SQL you could do something like this:
Replace the page ID with the actual page Id to which you want to redirect the user.
BEGIN
IF(CONDITION)THEN
htp.init;
owa_util.redirect_url('f?p=&APP_ID.:10:&APP_SESSION.'); /*Replace 10 with actual Page Number*/
apex_application.stop_apex_engine;
ELSE
htp.init;
owa_util.redirect_url('f?p=&APP_ID.:20:&APP_SESSION.'); /*Replace 20 with actual Page Number*/
apex_application.stop_apex_engine;
END IF;
END;
Or you could use the APEX_UTIL.REDIRECT_URL procedure.
if you are using APEX 4.2 refer the APEX_UTIL reference from here.
You can use:
apex_util.redirect_url(
p_url => 'type your url here'
);
This effectively calls in the owa_util. redirect_url and automatically calls apex_application.stop_apex_engine.

Populating a text box from from the value in a drop down

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).

Resources