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 

industriesserviceprocess

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.

1public class StopCheckPayment implements industriesserviceprocess.ServiceProcessRequestPreProcessor {
2  public industriesserviceprocess.ServiceProcessPreProcessorResponse processServiceProcessRequest
3        (String serviceProcessDefId, Map<String, Object> caseInfo, Map<String, Object> serviceProcessAttrs) {
4            industriesserviceprocess.ServiceProcessPreProcessorResponse response = null;    
5            Date paymentDate = (Date) serviceProcessAttrs.get('paymentDate');
6            if(paymentDate < Date.today()) {
7                response = 
8                new industriesserviceprocess.ServiceProcessPreProcessorResponse('Payment Date cannot be before the current date',
9                          false, industriesserviceprocess.ServiceProcessPreProcessorErrorTypes.VALIDATION_ERROR);
10            } else {
11                response = 
12                new industriesserviceprocess.ServiceProcessPreProcessorResponse(true);
13            }
14            return response;
15        }
16}