Set page item value to show in DA confirm message - oracle

I'm using Oracle Apex Version: 20.1
I have a page item (:P303_ADJUSTAMOUNT) that has a default value that's set via sql query. When the user presses the submit button, I have a DA confirm action that shows a popup window to confirm the amount the user is trying to adjust. This works if the user doesn't change the page item value after initialization, as the modal window displays the value that was retrieved from the sql query (the item's default value).
I created another DA on the page item itself to set the value of the page item on the "Lose Focus" event (Set Value --> PL/SQL). I want the DA to set the item's value to whatever the user has entered at the time. Yet when my confirmation message pops up, the page item is still set to the default value and the value I entered disappears. Where am I going wrong here?
Set Value Dynamic Action
Confirmation Message
Update on 04/26/2022:
I finally got my message to be able to display the page item's value and not the page item's session state value. But I have a feeling I'm doing a little extra work to get the desired result.
New code for dynamic action
Action: Execute JavaScript Code
Code:
var msg;
var amt;
msg = "Are you sure you want to insert a singleton for $"
amt = apex.item( "P303_ADJUSTAMOUNT" ).getValue();
apex.message.confirm(msg.concat(amt,"?"), function( okPressed ) {
if( okPressed ) {
apex.submit('ADJUST');
}
});
Desired Result: Update Confirmation Message

Related

ORACLE APEX - Set up a Button to populate a textfield

I have a button which I would like to take the Input text field called P7_INPUT and Divide (/) it by 2000 and pop it into the P7_OUTPUT
Users enters say 3000 into P7_INPUT field and pressed the Button then in the P7_OUTPUT is will show the value of 1.5
Right-click on the :P7_INPUT and select Create Dynamic Action. Set the following properties:
Event: Key Release
Selection Type: Items(s)
Item: P7_INPUT
Right-click the dynamic action and select either Create TRUE Action. Set the following properties:
Action: Set Value
Set Type: PL/SQL expression
PL/SQL expression : NVL(:P7_INPUT,0) / 2000
Items to Submit: P7_INPUT
Affected Elements > Selection Type: Item(s)
Affected Elements > Item(s): P7_OUTPUT
You don't even need a button.
create P7_INPUT as a text item; set its "Submit when enter pressed" property to YES
create P7_OUTPUT
create a process which will contain a PL/SQL code:
:P7_OUTPUT := :P7_INPUT / 2000;
That's all; when you enter e.g. 3000 into the input item and press enter, process will do the calculation and display the result in the output item.
If it must be with a button, create it and let it submit the page. Process will look the same, you'd just put P7_BUTTON into process' "Server side condition's" "When button pressed" property.
Since you require the action to occur dynamically when the user clicks a button, I would create a Dynamic Action on button click with a Set Value action for P7_OUTPUT set to a JavaScript expression:
parseFloat($v("P7_INPUT)) / 2000
This avoids a server round-trip.

Oracle Apex button click it will open new window

Oracle Apex 5.1, once click the button it will open new window its possible?, any one please provide the sample code
Use the below code
javascript:window.open('f?p=&APP_ID.:1:&SESSION.:::1:P1_ID:'+$v("P844_ID")+','_blank');
In dynamic action : create an on click DA that executes JS
var rowid= this.triggeringElement.id;
vUrl = apex.util.makeApplicationUrl({
//appId: $v("pFlowId"), // default is $v("pFlowId") - current app
pageId:10, // default is $v("pFlowStepId") - current page
//session: $v( "pInstance" ), // default is $v("pInstance") - current session
// request: 'TEST_REQUEST', // default is $v("pRequest") - current request
//debug: 'YES', // default is $v("pdebug") - debug YES/NO
itemNames:['P10_SHP_APPLICATIONS_TBL_ROWID'],
// item names array (no value by default)
itemValues:[rowid] // item values array (no value by default)
//printerFriendly: 'YES' // no value by default
});//console.log(vUrl);
window.open(vUrl);
LMGTFY - Did you try the following
APEX open URL in new window
javascript:window.open('f?p=&APP_ID.:3002:&SESSION.:::3002:P3002_CPY_ID,P3002_RPM_ID,P3002_ACM_ID, P3002_FORMAT,P3002_REPORT_PAGE_NO:'+$v("P1977_CPY_ID")+','+$v("P1977_RPM_ID")+','+$v("P1977_ACM_ID")+',VIEW,1977','_blank');
Use the above code
Click the button and create the dynamic action and select Execute Js and paste the query.. pass the parameter and page no everything.. then try
Flow below step
Go to Button
Go to button Behavior
Action : Redirect to URL
javascript:window.open('f?p=&APP_ID.:1:&SESSION.::NO:1:P1_PID:'+$v("P2_PID")+'');

Delete Record VB2010 w/ TableAdapter

This shouldn't be this hard... But it's late.
I am working on a simple form, and trying to delete a record from a connected DataSource while using a TableAdapter. Here is the SQL for the TableAdapter;
DELETE FROM Main WHERE (ID = ?) AND (tbl_Job_Name = ?)
Main is the table name, only two fields.
I am populating a ComboBox with this data, and I am using a Button to call the Delete() action like this;
Private Sub btnDeleteJob_Click(sender As Object, e As System.EventArgs) Handles btnDeleteJob.Click
Dim deleteJobAdapter As New DCGDataSetTableAdapters.MainTableAdapter
deleteJobAdapter.DeleteQuery(ComboBox2.SelectedIndex, ComboBox2.SelectedText)
End Sub
When I break the code I can see the ID value, but the SelectedText field is blank, and of course when it runs through the record is not deleted. I would ideally like to just pass the ID of the selected record in the ComboBox to delete the record. What am I missing?
Try,
deleteJobAdapter.DeleteQuery(ComboBox2.SelectedIndex, ComboBox2.Text)
SelectedText property:
Gets or sets the text that is selected in the editable portion of a ComboBox.
Text property:
Gets or sets the text associated with this control.
You can use the SelectedText property to retrieve or change the currently selected text in a ComboBox control. However, you should be aware that the selection can change automatically because of user interaction. For example, if you retrieve the SelectedText value in a button Click event handler, the value will be an empty string. This is because the selection is automatically cleared when the input focus moves from the combo box to the button.
When the combo box loses focus, the selection point moves to the beginning of the text and any selected text becomes unselected. In this case, getting the SelectedText property retrieves an empty string, and setting the SelectedText property adds the specified value to the beginning of the text.
When I enter the code;
deleteJobAdapter.DeleteQuery(ComboBox2.SelectedIndex, ComboBox2.Text)
My break point shows the correct text from the record, but I did notice that the ID value is incorrect, the SelectedIndex returns a sequential number of the record itself, starting with "0". So it looks like SelectedIndex does not return the actual ID value...
And back to the original issue, the record selected is still not deleted.
This is what I ended up using;
Dim delJobID = ComboBox2.SelectedValue
Dim delJobRowAdpt As New DCGDataSetTableAdapters.MainTableAdapter
Dim delJobRow As DCGDataSet.MainRow
Dim intDelete As Integer
delJobRow = DCGDataSet.Main.FindByID(delJobID)
delJobRow.Delete()

LiveCycle drop-down list change event only works on second change

I want a Text Field to appear when a certain item is chosen from a drop-down list. I'm using a change event.
if(this.rawValue == 1){
Tolerance.presence = "visible";
}
else{
Tolerance.presence = "hidden";
}
The problem is that the Text Field presence does not change immediately when a selection is made, but only after I go back to the list box and select again (any value, not just the same one).
The new value of the dropdown only registers after the change event. This means this.rawValue points to the old value of the dropdown in a change event.
Either move your script dropdown exit event or make use of the event.newText in the if conditional in the change event.

XPages: how to count paginated view panel rows

I have a view panel in xpages and a computed field to show the row-count. I have 2 problems:
1st: how can i count only the rows of the current page of the pager?it seems that viewPanel.getRowCount() gets all rows from the beginning until the current page, so if i have 30 entries per page and i am in page 2, it shows 60 instead of 30.
2nd: even if i achieve the above, the pager only refreshes the view and i can't refresh the computed field or another panel. Can i put the computed field inside the view panel or make it somehow to be refreshed in each page change? i would prefer not to do it with full page refresh if possible...
Given the computed field refresh issue, even if you managed to get a count of rows (eg on a page-scope SSJS variable), it woudln't update the computed field.
It might be easier to to count to rows in the HTML table using clientside javascript ?
something like ..
page onload event :
get the HTML table
get the table rows property (array of rows in the table)
number or rows = that value (1st row = TH (header) row if there is one = row 0)
use javsscript to plug that value into a known DIV
You could also hijack the partial refresh issued from the pager and check for the ID that has been refreshed. If the ID match your view panel's ID, you could do another partial update in order to update another panel.
Example code for hijacking the partial refresh:
var sysHijackPartialRefresh = function(){
XSP._inheritedPartialRefresh = XSP._partialRefresh;
XSP._partialRefresh = function( method, form, refreshId,options) {
if (options){
if (!options.onComplete) {
options.onStart = function(){
};
options.onComplete = function(){
if (refreshId == "<client id of view panel>") {
// issue another partial refresh
XSP.partialRefreshGet(<client id of the other panel>);
}
};
}
}
this._inheritedPartialRefresh(method, form, refreshId, options); }
}
XSP.addOnLoad(sysHijackPartialRefresh);
See http://xpageswiki.com/web/youatnotes/wiki-xpages.nsf/dx/Work_with_events_and_partial_or_full_refresh for more information about partial updates.
The pager should have a "refreshID" property in which you can put the client ID (!) of the panel you want to refresh. Use getClientId() to compute the client ID of the panel.
For the row count: use the XPages debug toolbar (from openNTF) to check for a property of the view panel or the pager which gives you the current page number. If you got that, you can simply compute by using viewPanel.getRowCount() - (page number * number of rows per page).

Resources