Service Classes and Methods
Service Classes and Methods
A service class is a Java class that holds a collection of methods that provide a related set of business functionality
public class LeaseAlertHandlers {
... event-handler method(s) will go here ...
}
The service class can contain:
- One or more service methods that will be automatically exposed as workflow rules; each service method implements a single workflow rule.
- Additional private helper methods that are called from the service methods; these methods are not required and are used simply as means of structuring and reusing the code according to programming practice.
Service methods must be public Java methods that can take zero or more arguments, and can return a single return value or no value at all:
public void generateAlerts() {
... event-handler code will go here ...
}
public DataSet getAlerts(List<String> leaseIds, Date dateFrom) {
... service code will go here ...
}
You can still use the old-style signature that accepts a single parameter of type
EventHandlerContext
and can only return values by adding them as response parameters to that context, but this is neither required nor recommonded, as long as you use the class-level workflow rule security (one Workflow Rules table record per service class).
The service method names are not referenced from the Workflow Rules table - only the service class name is. To call a workflow rule, specify the application ID, the rule ID, and the service method name in the view command or in the Java Script Workflow.callMerthod() function:.
<command type="workflowRule" ruleId="AbLeaseAdministration-LeaseAlertHandlers-generateAlerts"/>
try {
var result = Workflow.callMethod('AbLeaseAdministration-LeaseAlertHandlers-getAlerts',
leaseIds, dateFrom);
var dataSet = result.dataSet;
...
} catch (e) {
Workflow.handleError(e);
}