How To - Extend or change an existing validation message

This section describes how you customize a validation message, PM_DataItemValidate, in an existing form.

The example is using the steps described in A Simple Client Customization as base, followed by additional steps about how to extend the validation message.

 

Pre-Requirements

A Simple Client Customization getting a customized form window named frmPersonInfo_Cust.

Extended an existing validation message

Result

Once the field dfsName is validated, apart from the standard logic that opens up a dialog for editing values, an extended validation will executed that will pop a message box if the entered name starts with "A" or "a".

Change an existing validation message

To change the base implementation of the existing validation, the step needed are very similar to the above, with the exception skipping the "base" call by exclude the call to Sal.SendClassMessage.

 
...
private void dfsName_OnPM_DataItemValidate(object sender, WindowActionsEventArgs e)
{
   e.Handled = true;
   // First, call the base implementation.
   //e.Return = Sal.SendClassMessage(Ifs.Fnd.ApplicationForms.Const.PM_DataItemValidate, Sys.wParam, Sys.lParam);
   e.Return = Sys.VALIDATE_Ok;
   if (e.Return == Sys.VALIDATE_Ok)
   {
      // Proceed with an extended validation.
      if (!this.ExtendedNameValidation())
         // Extended validation failed -> Return VALIDATE_Cancel.
         e.Return = Sys.VALIDATE_Cancel;
   }
}
...

Result

Once the field dfsName is validated, an custom validation will be made that will pop a message box if a name starts with "A" or "a". The standard validation opening a dialog box for entering values will not be run.

Note: Above example should be written much simpler, removing the initial assignment for e.Return. The purpose is simply to demonstrate the both scenarios, calling and not calling the base validation, using as little source code changes as possible.

Conclusion

Executing a base implementation of a message is done by calling the Sal.SendClassMessage, using the message constant as parameter. By doing that, the message will be "extended". Compared to methods, this is the very same as overriding a method named <MethodName> and first calling its base.<MethodName>.

Excluding a base implementation of a message is done by only executing custom logic, not calling Sal.SendClassMessage. The message will then be "changed".