'Suppress/clear messages in oracle forms 10g
I have some validation code that, when a user tries to save, will run through some complex business rules and determine if the current data entered matches the rules enough so to allow a save. If not, an error message telling them what rule is in violation is put at the bottom of the screen using message('All foos of type bar must qux.').
When they exit the form, it also runs against validation, and if successful, asks them if they want to save (using the built in question). If not successful, I have an alert that informs them all data will be lost and asks if they still wish to exit. The trouble is, when they click 'Exit Anyway', the validation message pops up. Once they click ok, the form closes as expected.
I'm attempting to suppress/clear messages so that this popup doesn't happen. I've tried changing the message level but it still pops up. I've tried sticking in a message('', NO_ACKNOWLEDGE) but that only lets me control where in my if/else chains I want the message to popup.
Is there some clear_messages or such I can do to just cancel all messages on the form waiting to be displayed?
As it currently stands, if I do
message('something')
I get a message in the status bar.
If I do
message('something')
message('something else')
the second one is in the message bar while the first one pop ups on the screen.
I am asking if there was a way to keep the first message from popping up. This is clearly something being done in oracle forms, and I've already explained a few attempts to clear it. Yes, I don't understand how to clear the status bar to keep the message from popping up, which is the whole reason I asked the question.
Perhaps I need to note why
message('something', no_acknowledge);
message('something else');
does not solve my problem?
If that is the case, the reason is because the first message is being printed out by a program unit where in all cases except this one, I want it to popup if another message comes in.
In other words, I have
function do_something return number is
...
begin
...
message('something');
...
end;
where do_something handles running against some business rules.
Elsewhere, in the key-exit trigger I have
...
if do_something = 0 then
if Show_Alert('Alert_that_explains_data_is_not_being_saved_due_to_validation_failure') = alert_button 1 then
exit_form(no_validate);
end if;
else
exit_form;
end if;
...
and in every other case except this one, when I call do_something, I want the message to pop up when another message is put on the status bar, but in this one case, I don't want it to be. As such, I'm asking if there is a way to clear the message or suppress it so that it doesn't pop up in this case.
Solution 1:[1]
You can set :system.message_level to some value > 0 to suppress certain levels of messages, and then set it back when you want normal processing.
From the online help within Forms Builder:
Working with Forms Runtime Messages
To control the messages that end users see when they use a Oracle Forms application, you can: use the SYSTEM.MESSAGE_LEVEL system variable to suppress specific "severity levels" of messages use On-Error and On-Message triggers to replace the standard processing of messages use the SYSTEM.SUPPRESS_WORKING system variable to prevent the update of an end user's screen (by suppressing the "Working..." message) Message Severity Levels
Forms Runtime messages are ranked by severity. Use the SYSTEM.MESSAGE_LEVEL system variable to can control the minimum severity level that displays to end users.
There are six levels of message severity that you can affect, listed here in increasing order of severity.
Level
Message Description
0
All types of messages from the other levels of severity.
5
Reaffirms an obvious condition.
10
Indicates that the end user has made a procedural mistake.
15
Declares that the end user is attempting to perform a function for which the form is not designed.
20
Indicates a condition where the end user cannot continue an intended action due to a problem with a trigger or another outstanding condition.
25
Indicates a condition that could result in the form performing incorrectly.
25
Indicates a message severity level that you cannot suppress via the SYSTEM.MESSAGE_LEVEL system variable.
Severity levels of individual Forms Runtime messages are labelled with "Level" in the Oracle Forms online help system. Message Types
To use On-Error and On-Message triggers to replace Forms Runtime messages, you need to be aware of the three types of Forms Runtime messages:
Informative Informs end users of the present state of processing (e.g., Last value retrieved.) or provides end users with context-sensitive guidance (e.g., Press [Accept] to enter answer.). Use the On-Message trigger to suppress the appearance of these messages.
Error Inform end users of error conditions that prevent the end user's actions (e.g., Function key not allowed. Press [Show Function Keys] for list of valid keys.). Use On-Error triggers to suppress the appearance of these messages. However, you cannot suppress error messages that appear on the command line (e.g., Too many arguments on command line.).
Working Inform end users that Oracle Forms currently is processing (e.g., Working...). You cannot use On-Error or On-Message triggers, or the SYSTEM.MESSAGE_LEVEL system variable to suppress these messages.
Message types of individual Forms Runtime messages are labelled with "Type" in the Form
Related topics
SYSTEM.MESSAGE_LEVEL examples
On-Error Trigger
On-Message Trigger
About handling runtime errors in triggers
Solution 2:[2]
I did come up with a solution for this, but not a great one. In the validation function I created, I passed another variable (an int that is set to either 0 or 1) that only indicates if I wanted the message to be a popup message or not, basically either calling message('warning...') or message('warning...', no_acknowledge). I then marked each call to the validate function if I wanted it to be displayed where it would popup or not.
I would still prefer a some way that I could call only in certain locations that would clear what ever message is at the bottom of the form so it does not popup even if it hasn't been set with no-acknowledge because my current solution does not seem optimal, but if anyone else is having the same issue, hopefully this will be able to work even if it doesn't look pretty.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | GriffeyDog |
| Solution 2 | Lawtonfogle |
