Skip to main content

Groovy Script - Validate the Combination of Purpose of Issue and Document Status Abbreviations

Description: Sample Groovy Script for validating the combination of Purpose of Issue and Document Status abbreviations.

Context: Document

Document Type: File

Remark: Accessible in 'Pre' or On-Load Mode only.

Script:

def execute(){

// Step 1: Create a HashMap to store options
HashMap<Object, Object> optionMap = new HashMap();

// Step 2: Set a specific option for abbreviation details
optionMap.put(RevisionDetailsOption.ABBREVIATION_DETAILS, true);

// Step 3: Retrieve document details based on options
DocumentVO document = documentService.getDocumentDetails(optionMap);

// Step 4: Retrieve POI and status abbreviations
String poiAbb = document.getPoiAbbreviation();
String statusAbb = document.getStatusAbbreviation();

// Step 5: Check for a specific combination of POI and status abbreviations
if (poiAbb.equals("P01") && (statusAbb.equals("S1") || statusAbb.equals("S2"))) {

// If the condition is met, set the response status to false and provide a response message
document.setResponseStatus(false);
document.setResponseMessage("Invalid combination of POI and status to upload file in this folder.");
}

// Step 6: Returns the 'document' object with validation error message
return document;
Did this answer your question?