Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Validate combination of Purpose of Issue and Document Status abbreviations
Groovy Script - Validate combination of Purpose of Issue and Document Status abbreviations
Updated over a month ago

Description: Sample groovy script to validate combination of purpose of issue and document status abbreviations.

Context: Document

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?