Skip to main content

Groovy Script – Validate DocRef Uniqueness at the Project Level (for Placeholders)

Updated over a week ago

Description: Sample Groovy script to validate DocRef uniqueness at the project level while excluding any linked documents (secondary or associated documents and attachments) from the validation check. This ensures accurate uniqueness verification across the project before processing.

Context: Document

Document Type: File or Placeholder

Remark: Accessible in Pre task 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 EXCLUDE_LINKED_DOCS to Excludes linked documents for accurate uniqueness checking.

optionMap.put(RevisionDetailsOption.EXCLUDE_LINKED_DOCS, true);

// Step 3: Retrieve document details

DocumentVO document = placeholderService.getPlaceholderDetails();

Set<String> attributes = [IDocumentAttribute.DOC_REF] as Set

// Step 4: Check for document existence at the project level , Ensures uniqueness of DocRef within the project.

Set<String> existAttributes = placeholderService.isAttributeValueExist(document, attributes,

RevisionDetailsOption.PROJECT_LEVEL_UNIQUE, optionMap);

// Step 5: Set response status and message if document exists , Indicates a conflict for user action.

if (existAttributes.contains(IDocumentAttribute.DOC_REF)) {

document.setResponseStatus(false);

document.setResponseMessage(document.getDocRef() + " : DocRef already exists in other folder, please update.");

}

// Step 5: Return the document after execution

return document;

}


Did this answer your question?