Warning function
Syntax
Warning str
Description
You typically use the Warning function in FieldEdit or SaveEdit PeopleCode to display a message alerting the end user about a potentially incorrect data entry or change. It differs from the Error function in that it does not prevent the end user from taking an action, and it does not stop processing in the PeopleCode program where it occurs.
Warning is also used in RowDelete and RowSelect PeopleCode, where its behavior is specialized. See the following sections Warnings in RowDelete and Warnings in RowSelect.
The text of the warning message (the str parameter), should always be stored in the Message Catalog and retrieved using the MsgGet or MsgGetText function. This makes it easier to translate the text, and it also enables you to include more detailed Explain text about the warning.
Note:
If you pass a string to the Warning function instead of using a Message Catalog function, the explanation text from the last call to the Message Catalog may be appended to the message. This can cause unexpected results.
See WinMessage function.
Parameters
| Parameter | Description |
|---|---|
|
str |
A string containing the text of the warning message. This string should always be stored in the Message Catalog and retrieved using the MsgGet or MsgGetText function. This makes translation easier and also enables you to provide detailed Explain text about the warning. |
Returns
None.
Example
The following example shows a warning that alerts an end user to a possible error, but allows the end user to accept the change:
If All(RETURN_DT, BEGIN_DT) And
8 * (RETURN_DT - BEGIN_DT) < (DURATION_DAYS * 8 + DURATION_HOURS) Then
Warning MsgGet(1000, 1, "Duration of absence exceeds standard hours for number of days absent.");
End-If;
Warnings in FieldEdit and SaveEdit
The primary use of Warning is in FieldEdit and SaveEdit PeopleCode:
-
In FieldEdit, Warning displays a message and highlights the relevant field.
-
In SaveEdit, Warning displays a message, but does not highlight any field. You can move the cursor to a specific field using the SetCursorPos function.
Warnings in RowDelete
When the end user attempts to delete a row of data, the system first prompts for confirmation. If the end user confirms, the RowDelete event fires. A Warning in the RowDelete event displays a warning message with OK and Cancel buttons. If the end user clicks OK, the row is deleted. If the end user clicks Cancel, the row is not deleted.
Warnings in RowSelect
The behavior of Warning in RowSelect is totally anomalous and maintained for backward compatibility only. Use it to filter rows being added to a page scroll after the rows have been selected and brought to the component buffer. Warning causes the Component Processor to skip the current row (so that it is not added to the page scroll), then continue processing. No message is displayed.
Note:
Do not use Warning in this fashion. Use the DiscardRow function for replacement instead.
See DiscardRow function.
Warnings in Other Events
Do not use the Warning function in any of the remaining events, which include:
-
FieldDefault
-
FieldFormula
-
RowInit
-
FieldChange
-
RowInsert
-
SavePreChange
-
SavePostChange
Related Topics