ORACLE APEX: Getting the value from page item and use it to another page item - oracle-apex

I have two forms:
first one:
5000_Works,
with items:
P5000_ID,
P5000_Working_Date,
P5000_QTY
and the second form:
5001_Tasks,
with items:
P5001_ID,
P5001_QTY
I open the second form from the first one and i want to put the value of P5000_QTY to the second page item P5001_QTY.
How can i do that?
Thank you

One option is to create a button which - when pushed - redirects to another page in this application. When you click on the "Target" (in "Behavior" properties section), you can tell Apex to:
navigate to page 5001
set item P5001_QTY to value &P5000_QTY. Note leading ampersand & and trailing dot .
And that's it ...
If it isn't a button but a branch, the principle is the same - using the Link Builder you'd do exactly the same.

Related

Oracle APEX - hyperlink shown as text on a static region

I have a static region and I want to set it to some text with a hyperlink. Text comes from the database - returned by a function.
So I added a page item (P1_LINK_TEXT) to the page and added a computation to my page item that is set to PL/SQL expression:
MyFunction('MY_TEXT')
The region Header Text to &P1_LINK_TEXT.
It works great, except the hyperlink displayed as is - Click here
instead of displaying the link. I made sure that Attributes->Settings->Output As is set to HTML but still, the hyperlink is not displayed correctly. What am I doing wrong?
Use the escape filter to ensure html characters are not escaped. To display the item as html use this notation:
&P1_LINK_TEXT!RAW.

How to give link for 3 different URLs on single button using select list in oracle apex

If user selects one option from select list then that button should link to different URL, if user selects second option from that select list then that same button should land at another URL , Kindly help me in it using ORACLE APEX.
Create a page item P1_URL of type select list
Add a couple of entries - for this example I'm using static values but a query should work too. Make sure the return value of the entry contains the actual url:
Create a button with action "Submit Page"
Create a branch
Execution Options > Point > "Processing"
Type: "Url defined by Item (Redirect)"
Item: P1_URL
Run the page, when you click the button the page should redirect to the selected url.

APEX - double click on interactive gird

Below is my interactive grid. It shows data from v$sql_monitor view based on sql_id from list .
What I would like to do is to create double-click dynamic action on a record. This action would open new modal dialog and pass two parameters : 1. sql_id from list above 2.sql_exec_id from clicked record. Would you give me a few hints how to do it ? I guess a piece of Javascript code will be necessary :(
There are multiple options to do this - here is one way, by using javascript custom events. I created a sample with an IG on the EMP/DEPT sample dataset with page 88 as IG and page 90 as modal. The column ENAME is a link to page 90 that sets a column value and a page item in the link.
Page 88 has an IG and 2 page items:
P88_PAGE_ITEM (a value entered on the page like the list in your screenshot)
P88_ENAME (to hold the selected report column value
Page 90 has 2 page items: P90_PAGE_ITEM and P90_REPORT_COLUMN
Create IG on page 90 on table EMP
On column ENAME, add the following under "JavaScript Initialization Code"
function(config) {
config.defaultGridColumnOptions = {
cellTemplate: '<button type="button" class="t-Button t-Button--link my-ename-js" data-ename="&ENAME.">&ENAME.</button>'
};
return config;
}
This is a button of type "display as link", created with the universal theme button builder that has 2 extra attributes: a class my-ename-js and a data attribute "ename" data-ename="&ENAME."
Create a dynamic action to capture the click and set the page item:
Make sure to set the scope to "Dynamic". This is needed because the event listener needs to be added again after a dom change (a search or filter of the IG).
add a true action of type "Set Value" to set the value of P88_ENAME to the value of the selected row
add a second true action to trigger a custom javascript event:
Create a dynamic action of type "Event: Custom" to capture the custom event triggered in the previous DA.
add a true action of type "Submit Page". Note that "Show Processing" needs to be unchecked.
Almost there. One last thing is to create a branch to the modal page:
Create a branch (process point "After Processing") with server-side condition of "Request = Value" with value OPENMODAL and link attributes below:
And this should be the result:
Well, I modified a bit your scenario.
I added new SelectList P88_FILTER
and added dynamic action ON_CHANGE :
with action
I modified source if IG:
These changes allowes me to filter IG . In our case filter returns always only one record like below.
and now my problem begins. In your scenario clicking the link "ename" updates field P88_ENAME and opens modal dialog with proper values. After my modification neither P88_ENAME updates nor modal dialog opens :(

Oracle Apex Checkbox Group, disable item option

It is possible to disable one option of checkbox group? I have created an P100_CREATE_PT item and disable one option using JavaScript:
const nodeList = document.querySelector("#P100_CREATE_PT_0");
if(nodeList) {
nodeList.disabled = 'disabled';
nodeList.checked = true;
}
But there is one problem: after page submit Checkbox Group item is null (undefined), but if disabled option is not set - item is not null, is okay. Where is problem?
In details: I have P100_CREATE_PT Checkbox Group Item with 3 options. In block JavaScript: Execute when Page Loads, I'm running JavaScript code, when page is loaded, first Checkbox Group option been disabled and checked - that what I need. When page submitted using button, Procesing runs the code: APEX_ERROR.ADD_ERROR(p_message => :P110_CREATE_PT, p_display_location => APEX_ERROR.C_INLINE_IN_NOTIFICATION); and showing error message with empty value (P100_CREATE_PT). And there doesn't matter how many options selected. If option is not disabled, P100_CREATE_PT value been not null.
I can confirm that this doesn't work if the disabled value is the first checkbox. On page submit it does not set the value of the checkbox.
However the value is sent correctly in an on-change dynamic action.
So a workaround is to set a hidden item on change of the checkbox and use that in the page submit.

Oracle Apex How to display page item as url

I have a page item which stores URL.
How do i change its type to URL so that the link becomes clickable.
As of now, there is page subtype url, but setting it doesn't make any difference.
Apex 21.1
A text field is an html input element, that will display text only, you probably could write some javascript to open whatever is in the page item in an url but that is confusing functionality. What should happen if the user clicks in the input element ? Should it open the link or should the user be editing the value ?
This is a possibility.
Create a page item on your page, say P1_URL
Add the following in the "Post Text" attribute of the page item (style it to your own preference):
<span class="fa fa-external-link" aria-hidden="true"></span>
Add a dynamic action on change of the element P1_URL with a true action of "Execute Javascript Code" and the following code:
$("#myurl").attr("href", apex.item( "P13_URL" ).getValue())
Check "Fire on Initialization" for the true action.
That is all there is to it, now when you add something in the page item P1_URL and click the link, it will open the that url in a new window.
UPDATE: Technique for read only text field.
For a read only text field, the input element is hidden and an additional span element is rendered with an the page item name as id, suffixed by _DISPLAY. The trick is to grab the content of that span element and add an anchor with attributes. This can be done with an onload dynamic action:
Create a page item on your page, say P1_URL, set it to "Read-Only: Always"
Add a dynamic action on Page Load with a true action of "Execute Javascript Code" and the following code:
let itemVal = $("#P1_URL_DISPLAY").text()
$("#PP1_URL_DISPLAY").html(`<a href='${itemVal}' target='_blank'>${itemVal}</a>`)
Make sure that when you copy this, the quotes are exactly the same: the outer quotes are backticks, those are needed for the ES6 syntax.
Note: check the page documentation for the subtype url - it explains exactly what it does.