Skip to content

User-Defined Classes

User-defined classes (UDC) allow you to implement reusable logic into a single class, rather than repeating the same logic across multiple triggers on different objects. User-defined classes are then used by Vault extensions, such as triggers and actions. Developers can also use UDCs as an object to store complex data.

You can use UDCs to apply object-oriented solution designs by having interfaces, abstract classes, and class implementations in separate UDCs.

Unlike Vault extensions which execute when a user or the System initiates an operation, UDCs only execute by calls from other classes.

UDCs can use any of the following libraries and services:

  • Allowlisted JDK classes and methods
  • Vault Java SDK classes and services
  • Vault Application provided services
  • Other user-defined classes

A user-defined class is a Java class which uses the @UserDefinedClassInfo class annotation. For example, the following illustrates a user-defined class ValidationUtils:

@UserDefinedClassInfo public class ValidationUtils { boolean isNameFormatted (Record record) { String name = record.getValue("name__v", ValueType.STRING); if (name.length() < 100 && !name.substring(0,2).equals("BAC")) return true; else return false; } }

You can use a UDC in any Vault Java SDK extension, such as a trigger or an action class, as well as other UDCs. The following example illustrates a trigger using the ValidationUtils user-defined class:

@RecordTriggerInfo(object="product__v", events={RecordEvent.BEFORE_INSERT}) public class Example implements RecordTrigger { public void execute(RecordTriggerContext recordTriggerContext) { ValidationUtils validationUtils = new ValidationUtils(); for (RecordChange inputRecord : recordTriggerContext.getRecordChanges()) { if (!validationUtils.isNameFormatted(inputRecord)){ // set Name field to format required for this object } } } }

While debugging a trigger or action, you can step into UDCs to debug them. Because UDCs are not directly executable, you must step into them when calling them from an extension class.