ServiceProcessRequestPreProcessor Interface
Implement the ServiceProcessRequestPreProcessor interface to create a
preprocessor class that transforms and validates data for custom attributes in the Service
Catalog Connect REST API. Using a preprocessor is optional.
Namespace
ServiceProcessRequestPreProcessor Methods
The following are methods for ServiceProcessRequestPreProcessor.
processServiceProcessRequest(serviceProcessDefId, caseInfo, serviceProcessAttrs)
Transforms and validates Case attributes or service request
attributes. The processServiceProcessRequest is an abstract method.
Signature
ServiceProcessPreProcessorResponse processServiceProcessRequest(String serviceProcessDefId, Map<String, Object> caseInfo, Map<String, Object> serviceProcessAttrs)
Parameters
- serviceProcessDefId
- Type: String
- Represents the Developer Name of the service request.
- caseInfo
- Type: Map<String,Object>
- Represents Case attributes in the input payload in key-value pair format.
- serviceProcessAttrs
- Type: Map<String,Object>
- Represents service request attributes in the input payload in key-value pair format.
Return Value
Type: ServiceProcessPreProcessorResponse object
ServiceProcessRequestPreProcessor Example Implementation
This is an example implementation of the industriesserviceprocess.ServiceProcessRequestPreProcessor interface.
public class StopCheckPayment implements industriesserviceprocess.ServiceProcessRequestPreProcessor {
public industriesserviceprocess.ServiceProcessPreProcessorResponse processServiceProcessRequest
(String serviceProcessDefId, Map<String, Object> caseInfo, Map<String, Object> serviceProcessAttrs) {
industriesserviceprocess.ServiceProcessPreProcessorResponse response = null;
Date paymentDate = (Date) serviceProcessAttrs.get('paymentDate');
if(paymentDate < Date.today()) {
response =
new industriesserviceprocess.ServiceProcessPreProcessorResponse('Payment Date cannot be before the current date',
false, industriesserviceprocess.ServiceProcessPreProcessorErrorTypes.VALIDATION_ERROR);
} else {
response =
new industriesserviceprocess.ServiceProcessPreProcessorResponse(true);
}
return response;
}
}