How to change a "hidden variable" to NULL whenever page is reloaded - oracle-apex

Please explain how to change a "hidden variable", say p_show_variable, to NULL whenever page is reloaded.
I have a conditional report in a page , and the requirement is whenever any variable changes and that "Submits" the page , then p_show_variable should become NULL, thus hiding the conditional report.

Create unconditional PL/SQL proccess on your Page Rendering. Add some code:
BEGIN
:P_SHOW_VARIABLE := NULL;
END;
You can also add some condition on proccess, for example, Request=Expression. Change button action to Redirect and set Request value. Use this value as Expression in process condition.
Or set condition for proccess When Button pressed and set button name.

Related

How to automatically run a VBA macro (to do regex replacement of e-mail body text) when Outlook inspector has opened a reply/forward e-mail?

I have an Outlook VBA macro that does a regex replacement of some text in a reply/forward e-mail, using the WordMail representation of the e-mail.
I can trigger it from a button added to the ribbon. I want it to execute automatically immediately the inspector has opened, i.e. remove the need to remember to press the button once the editor is displayed. I have tried overloading the Open event, but the message does not appear to be accessible at that point - I think this gets invoked too early. None of the other events appears to be at the correct time.
Thank you for any suggestions.
There are multiple events that you consider handling for such purposes.
The very first option is to handle the NewInspector event which is fired whenever a new inspector window is opened, either as a result of user action or through program code The inspector that was opened is passed as a parameter, so you can subscribe to the Activate event which is fired when an inspector becomes the active window, either as a result of user action or through program code. So, at this stage the item and the inspector window have been initialized and you are free to do any customizations.
You may find the Implement a wrapper for inspectors and track item-level events in each inspector article helpful.
The second option is to handle the MailItem.Reply event which is fired when the user selects the Reply action for an item, or when the Reply method is called for the item, which is an instance of the parent object.
Inspectors.NewInspector event
Occurs whenever a new inspector window is opened, either as a result of user action or through program code
Option Explicit
' In ThisOutlookSession
Private WithEvents myOlInspectors As Inspectors
Private Sub Application_Startup_Temporary()
Set myOlInspectors = Application.Inspectors
End Sub
Private Sub myOlInspectors_NewInspector(ByVal oInspector As Inspector)
' https://learn.microsoft.com/en-us/office/vba/api/outlook.inspectors.newinspector
' Occurs whenever a new inspector window is opened,
' either as a result of user action or through program code
Dim msg As MailItem
If oInspector.CurrentItem.Class = olMail Then
Set msg = oInspector.CurrentItem
If msg.Size > 0 Then
Debug.Print "Subject: " & msg.subject
Debug.Print " Non-zero size message opened."
' Your code here
End If
End If
End Sub
Private Sub myOlInspectors_NewInspector_Test()
myOlInspectors_NewInspector ActiveInspector
End Sub

Calling page in a new tab when an item's value changes

I am using apex 21.1.
I have built a report with a form. The report page(2) has another region "Param" which has item P2_DEPTNO. The form(Modal Page -3) is for creating new records and editing existing records. There is a CLOSE DIALOG process in page 3 and it has P3_DEPTNO as a value for "Items to Return" attribute. Page 2 has a DIALOG CLOSED dynamic action with a true action of SET VALUE that sets P2_DEPTNO with the value of P3_DEPTNO. This is when I should call page 4 in a new tab(when P2_DEPTNO is assigned P3_DEPTNO's value.I am calling page 4 using the code...
apex.navigation.openInNewWindow('f?p=&APP_ID.:4:&APP_SESSION.:::4');
Unfortunately, it does not work and I do not know why. However, if the dynamic action is of type Alert, it works fine and displays the alert when P2_DEPTNO's value changes. What could be the reason for that?
ws=ESLAM_WS
un= forhelp
pwd=Forhelppwd$
app= Call new window
pages= 2,3 and 4
P.S: It works if I change P2_DEPTNO's value manually. But I need it to work when the SET VALUE dynamic action set it's value.
I tried to log in into you app, added another dynamic action event "Execute Javascript code" and entered your code without ':::4' part and it worked well for me.
so:
apex.navigation.openInNewWindow('f?p=&APP_ID.:4:&APP_SESSION.');
(also I have left an alert there that you mentioned worked anyway). If someone else fixed it meantime, I hope she/he will document here what she/he did.

Execute query on active region

I have one page where i have about 8 tab region. Each region has a select statment. They are executed when accessing the page (page load) at the same time. Because i have 8 select statment that executes at same time it leads to pure performance.
My question is how to execute the query only on active region.
You can try this one
Create Dynamic Action on event "Page Load"
Create true action "Execute javaScript Code":
window.setTimeout(function(){
$('.a-Region-carouselLink').click(function(){
apex.event.trigger(document, 'tabChanged', this);
})
}, 500);
Set "Fire On Page Load" to "Yes"
Create Custom event "tabChanged"
Create true action in DA custom event "Execute JavaScript Code":
console.log(this.data);
Test it - each time you click the tab, DA prints to console currently clicked anchor.
Of course it is not perfect because of the 0.5s delay. Still it allows you to listen what tab was "clicked".
To make your scenario work I would do:
create page item PX_TAB
create true action in custom event to set value of PX_TAB
create true actions in custom event to refresh reports within tabs
set "Page Items to Submit" to "PX_TAB" in each report to be refreshed
add condition to each report comparing value of item PX_TAB - it will execute SQL query only when PX_TAB has expected value
edit 2016.08.13
You can bind tabs by simple adding listener to the tabs
$(document).on('mousedown', 'a.t-Tabs-link', function(){
//this is an anchor used as tab
console.log(this)
})
If you want to keep it in APEX way enter code from below in Execute when Page Loads page section or create new dynamic action On page load
$(document).on('mousedown', 'a.t-Tabs-link', function(){
apex.event.trigger(document,'tabChanged', this);
})
and then add dynamic action bound to Custom event named tabChanged. Whenever tab is clicked the tabChanged event is triggered, and in Execute JavaScript Code you can reference current tab by this.data
Try to create buttons and set behavior of each button to display required region and hide others (create hidden item, then create buttons that set values 1,2,3 etc., then add conditions to every region to display region 1 only when hidden item equal 1, region 2 for item value 2 etc.

MFC Spin/Edit Control

I am using an Spin Control with an Edit Control buddy. I have an OnEnChanged event as below
void MyClass::OnEnChangeSnrEdit()
{
UpdateData(TRUE);
wizard_data->wlan.min_snr = m_snr_spin.GetPos();
CheckValid();
}
CheckValid enables the next button on my dialog page if the value is within the range I want it to be. The problem I have is that if I manually delete the value from the Edit Control so it is blank then GetPos above returns 0. 0 is within the range I allow and so my Next button is enabled and the value 0 is set when there is actually no value in the Edit Control.
How do I solve this issue?
Simply check the Contents of the edit Control first. Only if it is not empty, then get the spin button Control.
But why to relay on the value of the spin Control. always use the value from the edit Control!

Save the state of QCheckBox in file, and load the state when program restarts

In my GUI application, I have some labels in my mainwindow the visibility of the labels are controlled from checkboxes in a dialog which opens when a button (setting) is pressed. Now, it all works fine, i.e. if I open the settings dialog I can check or uncheck the checkboxes; consequently the labels are also set visible or invisible.
mysettingsdialog.cpp
void mysettingsdialog::onclick(bool checked) //by AJ kpi conf
{
if(myCheckBox->isChecked()==true)
{
emit setlabelvisible();
}
else
{
emit setlabelinvisible();
}
}
mainwindow.cpp
MySettingsDialog* myset=new MySettingsDialog(this);
connect(myset,SIGNAL(setlabelvisible()),this,SLOT(enable1()));
connect(myset,SIGNAL(setlabelinvisible()),this,SLOT(disable1()));
void MainWindow::enable1()
{
ui->label->setVisible(true);
qDebug()<<"VISIBLE label";
}
void MainWindow::disable1()
{
ui->label->setVisible(false);
qDebug()<<"INVISIBLE label";
}
Now the problem is, every time my application restarts it does not retain the previous state of the checkboxes. So I was thinking to save the state of the checkbox in a variable and writing it to a file, so whenever my application starts it will read the file and set the status of check box accordingly.
My question is, how can I store the "state" of checkbox in a variable and write it to file. And again use the same to set the state of checkbox ???
I mean reading / writing values from file for QLabels and QLineEdits is easy enough but I am baffled about how to do it with checkbox.
Create a container to store the pointer of each checkbox.
Create another container to store the "state" of each checkbox. For a binary check box, you can use isChecked() to query whether or not a checkbox is checked. Otherwise you can call checkState() to return the state as enum if you use a tri-state check box (see the edit).
When loading settings, assign the state to each check box accordingly.
You may use QSettings to manage the settings and save them as an ini file.
Edit
Just mention there is an option for a tri-state check box. From the document:
QCheckBox optionally provides a third state to indicate "no change".
This is useful whenever you need to give the user the option of
neither checking nor unchecking a checkbox. If you need this third
state, enable it with setTristate(), and use checkState() to query the
current toggle state.