...
Sets a validation error message. This messages output in the UI if the validation logic returns falseError message must be addressed by the User before a record is allowed to be altered. If this function is called multiple times, only the message from the last calls is displayed.
...
Sets the validation warning message. This messages output in the UI only if the logic does not return false. Warning messages can be used for informational purposes and can be ignored by the User to allow altering a record after viewing the message If this function is called multiple times, only the message from the last calls is displayed.
...
Once a Custom Validation has been triggered, regardless of what data input method triggers the Validation, a message will be reported back to the User identifying itself as a result of Custom Validation. The first part of the error will display the name of the organization to help identify that the error was a Custom Validation and not one of the standard errors from the application. The message from the Validation will appear after the name.
These two functions setError() and setWarning() can have a number of different returns. In additional to the message set, the return will also determine behavior. The following table explains the expected results of using either function and the return values.
Function | Return | Result |
---|---|---|
setError() | false | The Error is issued, Save or Delete fails |
setError() | not-false | Warning issued, save passes |
setWarning() | false | Error issued, save fails Note: An additional generic Error line will display because a false return implies an error message should have been set and was not. |
setWarning() | not-false | Warning issued, save passes. |
setError() + setWarning() | false | Error issued with both messages, save fails. |
setError() + setWarning() | not-false | Warning issued with both messages, save passes. |
For all of the following examples, a Custom Validation was written to require a Reference on all Services.
...