Writing Validation

Each preference object available inside the method gives access to all the fields available for marking in error.

Based on your requirements, if a validation condition fails, the field can be obtained, an error is set, and the field is added to the ValidationResults object before it is returned. If the preference itself needs to be set in error, a message can be directly added to the ValidationResults object:
public ValidationResults validateContact(Validation mode, Contact contact)
{
     ValidationResults valResults = new ValidationResults();
     If(//condition failed)
     {
          Field firstName = contact.getFirstNameField();
          firstName.setErrorText(“error”);
          valResults.addField(firstName);
     }
     return valResults;
}
A Table validation method works in same way, but instead of setting the error on Field and then adding it to the ValidationResults object, the error message is added:
public ValidationResults validateContacts(Validation mode, List<Contact> records)
{
     ValidationResults valResults = new ValidationResults();
     if(//condition failed)
     {
          valResults.addMessageText(“error”);
     }
     return valResults;
}

You can also write your own user exit by extending the ParticipantValidation class and overriding only the methods that you want by following the sample as an example.

Javadoc information

All the information on available preference classes and available fields for each preference can be accessed by opening the included index.html file through a browser. index.html is included in the userexit.zip file, which can be located in the artifacts container for your FTM offering.

For more information about getting the sample user exit file from the artifact pod and installing it in the correct location, see User exits for the FTM components.