I'm using Application Express to build a page with a form that shows all the rows in Table A. Table A has to contain all the values from Table B that have a specific "Status".
I'm looking for a way to update Table A so that new rows with the correct status from Table B are added to Table A.
Is there a way to add a button to the page that inserts into Table A those rows? I have no problems with coding the query itself, but on Apex' Page Designer, when I add a button (which I called Refresh) to the page, I can't find a place to add the Insert Query.
Any tips?
there are several ways to do what you need, the simplest one would be to bind a dynamic action to the click event on the button.
On the button definition go to "Action when button clicked" region and on the action field select "Defined by dynamic action"
On execute validations choose "No"
Then, back on the page definition, create a dynamic action, on Event choose "Click", on Selection type choose "Button" this will make a field named button appear whit a list of the available buttons to choose.
In condition you can define a true/false evaluation. if so then you would be able to define actions to execute in both cases, if you leave it empty ("No condition") then all the actions defined will be executed.
Once defined click next and here you decide the action type, the one you need is "Execute PL/SQL Code", which will show a text field on which you can paste your code, and the parameters needed from the page.
finally you can specify if the action will have a repercussion on any kind of visual component on the page, this is for efficiency, but is not necessary.
That would be all, once created, when you click the button the code will be executed on the server.
Related
I am selecting a value from LoV.Then i am clicking a button to trigger dynamic action(When->event=click,selection type->Button,Button name).Then in Server-side Condition i am putting (rows return->select * from tab)--Its triggering as expected,But if i will change sql query (select * from tab where col=:Lov)(there is 1 record,but its not triggering).
The reason why it is not triggered, is because a server-side condition tells APEX whether or not to load the defined Dynamic Action when rendering the page.
In your first example, the query select * from tab will return rows. So when rendering the page, the dynamic action will be loaded and executed when the button has been pressed.
In your second example, including the where clause select * from tab col=:Lov, page item :lov is most likely still empty when rendering the page and therefore the dynamic action is not being loaded and doesn’t exist for the browser at the moment you press the button.
Server-side condition is not the right solution here.
If you want the dynamic action only being executed when the selected lov item also exist in a table.
In APEX 5.1 you can execute an AJAX call in your DA to check the row existence before executing the actual logic.
In APEX 19.2 you can define extra output columns in a LOV, which you can use to set an additional page item. Set that item as an indicator (Y/N) to run the DA. Then you can use the Client-side condition to determine whether or not the DA should be executed, based on the indicator.
Hope this helps. Let me know when you need further assistence with one of the two solutions.
I am using Oracle Apex 18.2.
I have an interactive grid and a custom button to add a new row to the IG using,
apex.region("myRegionStaticId").widget().interactiveGrid('getActions').invoke('row-add-row'); then set a column's value using, $s("myColumnStaticId","2");. When I try it, it adds the first row without setting any columns' values and starts setting the value from the second row on. Even using selection-add-row or insert-record, there is always something with the first row. Here is a sample,
[https://apex.oracle.com][1]
ws = ESLAM_WS
user = forhelp
pwd = forhelppwd
app = TEST
page = Add Row on top of an IG.
After a lot of talking and testing, I've found that $s with setTimeout isn't very reliable. I've set up page 7 again to demonstrate.
If you click the Rowaddrow button twice in rapid succession (the second time before the first setValue returns), the second row will not be initialized. I'll show you a workaround for this below, but you'll
If you lower the setTimeout to, say, 10 ms, and try focusing in the Expiry Date column before clicking the Rowaddrow button, you'll find it doesn't work. This means that, while the setTimeout of 100 ms works now, it could break in the future if the IGs internal logic changed. Unlikely but who knows.
For the moment, I would say that $s can only be reliably used to set a column value in an IG for the active row. When the row-add-row action adds a new record, it does make it active, but that is done asynchronously via setTimeout. This is because the IG is based on the flyweight pattern and there are a number of async (setTimeout based) heuristics that are built in to handle focus and blur events to correctly enable and disable rows and cells as needed.
I've found the following to be the most reliable solution. Unfortunately, it's more complex than what you had before - but it was the only way I could wrangle it all together. Feel free to use it or not. See page 8 for an example.
Right-click the custom Rowaddrow button and select Create Dynamic Action. Set the Name of the DA to rowAddRow button clicked. The When settings will automatically be configured for the click event on the button.
Select the action for the new DA. Set Action to Execute JavaScript and enter the following JavaScript in the Code attribute.
addRowClicked = true; // Global used to distinguish custom button click
this.triggeringElement.disabled = true; // Disable button to serialize access
apex.region("KITCHEN_SHARE_DTL").widget().interactiveGrid("getActions").invoke("row-add-row");
Create a new Dynamic Action and set the Name to New row initialized. In the When section, set Event to Row Initialization [Interactive Grid], Section Type to Region, and Region to KITCHEN_SHARE_DTL.
Under Client-Side Condition, set Type to JavaScript expression and enter the following code in JavaScript Expression (which ensures the DA only fires for the click of the Rowaddrow button):
addRowClicked === true
Select the action for the new DA. Set Action to Set Value, Set Type to Static Assignment, and Value to 2. In Affected Elements, set Section Type to Column(s) and Column(s) to INGREDIENT_ID. This will replace the static assignment that was being done with $s. Ensure that Fire on Initialization is disabled.
Right-click the True branch for the DA and select Create TRUE Action. Set the Action to Set Value, Set Type to SQL Statement, and enter the following code in SQL Statement:
select MIN(EXPIRY_DATE) from stock
where ingredient_id = TO_NUMBER(:INGREDIENT_ID);
Set Items to Submit to INGREDIENT_ID and disable Escape Special Characters. In Affected Elements, set Selection Type to Column(s) and Column(s) to EXPIRY_DATE. Ensure that Fire on Initialization is disabled.
Right-click the True branch for the DA and select Create TRUE Action. Set Action to Execute JavaScript Code and enter the following JavaScript in the Code attribute.
addRowClicked = false; // Unset the global
$x('ADD').disabled = false; // Enable the button
Change the following code:
$s("INGREDIENT_ID","2");
with the following one:
setTimeout(function(){ $s("INGREDIENT_ID","2"); }, 100);
It seems that the IG needs a little time to render the new row before you are able to change any value.
I have several tabs. There is a date picker on each tab. I need that date to be the same on all tabs no matter what. So, if the user changes the date on Tab 1, then goes to tab 2, the date on tab 2 will have changed also. I have never created an application level item before and I thought that might be the most efficient way to accomplish what I need (by setting that item's value to the date the user selected). My problem is that I don't know how to set the value of the application item and also how to retrieve that value on another tab.
You didn't describe what exactly you're trying to do, but - if each tab represents its own table, why do you keep the same date value in all of them? Doesn't look like a normalized data model. Consider using a single date column (in one - master - table) and use (i.e. reference) it in others (i.e. details).
As of your question: How about creating a global page (i.e. page 0) and having a date picker item on it? You can display it on any other page you want. For example, if you set its value while on tab 1 and then move on to tab 3, you can again modify that value which will be visible on all other pages. Basically, you'd maintain just one item instead of as many as number of tabs involved. (BTW, doesn't that remind you of what I described in the first paragraph?).
Alternatively, create a date picker item on tab 1 page; on all other pages, create a "lookup" (display) item which would simply display what's been selected on tab 1. That's easy to do, just make its source to be an "Item", such as P1_DATE_ITEM.
In Shared Components > Application Items create new Item called G_DATE.
Then for every datepicker add Dynamic Action on Event Change.
In True action Set Value select Type PL/SQL Expression with code
:G_DATE := :P1_DATEPICKER1;
and Items to Submit :P1_DATEPICKER1
Next in every datepicker Source set Type PL/SQL Expression with code
:G_DATE
used Always (...)
Regards
Need a help in understand underline logic here. I have created a simple APEX application. First page shows the table details and via a "Create" button "Interactive Search" region, directs to a form page. Now form page consists of "Save" and "Insert" buttons in correct regions. So whole app works. When I press "Create" from 1st page to 2nd, "Save" button is invisible and when I click the edit icon on the table of 1st page, "Create" button is invisible in 2nd. App works accordingly, but could not figure out what setting enable this set-up even though I was able to make it work.
1st Page : Interactive Report Page. 2nd Page : DML Form. Built the app from blank pages.
Could any of you explain how it works?
When you click the Create button on the Interactive Report page, it takes you to the Form page in insert mode, i.e. it allows you to enter a new row into the table. Therefore, the Form page has the Create (and the Cancel) button.
On the other hand, when you click the Edit button on the Interactive Report, it takes you to the same Form page, but this time in edit mode which enables you to modify values (and save those changes with the Apply Changes / Save button), delete that row using the Delete button, or - as previously Cancel current operation.
If you look at Form page's buttons' properties, you'll see that they have Server-side Conditions set which are then used to render (or not) a certain button. For example, if the Form page number is 13 and the primary key column is set to the ID column, then these conditions look like this:
Create: P13_ID IS NULL (i.e. the primary key column value doesn't exist yet, which means that this is a brand new row)
Apply Chanages / Save: P13_ID IS NOT NULL (i.e. the primary key column value exists, which means that row you see was fetched from the database)
Delete: P13_ID IS NOT NULL (the same condition as for the Apply Chanages / Save button)
Cancel: it is always displayed.
I have created an interactive report in apex5.0 with below select:
SELECT article_code,article_desc,order_date, order_status
FROM table_order
WHERE status in ('SHIP','DELIVER','CANCEL');
I want for each row record to have a button that when click it calls another page.
How to do that??
There are a couple options.
Edit the column and change the type of the column to Link.
Create an html link with an href to the page you want. Choose type display, then turn of escaping special characters in the column properties.
Calling another page is declarative, out of the box behaviour, and you'll find such examples in the documentation.
Declarative
http://docs.oracle.com/database/apex-5.1/HTMDB/editing-interactive-reports-page-designer.htm#GUID-B30458D6-9678-40D4-A477-28EE466ED50A
As link column
http://docs.oracle.com/database/apex-5.1/HTMDB/editing-interactive-reports-in-component-view.htm#GUID-48AF053F-0E34-40FA-94FE-19C0400AD499
Manual
http://docs.oracle.com/database/apex-5.1/HTMDB/understanding-url-syntax.htm#HTMDB03019
Using dynamic action http://www.grassroots-oracle.com/2015/12/tutorial-include-action-button-in-report.html