Description: Sample Groovy Script to validate document reference uniqueness at the Project level for the first revision or issue only.
Context: Document
Document Type: File
Remark: Accessible in 'Pre' task mode only.
Script:
def execute(){
DocumentVO document = documentService.getDocumentDetails();
boolean isExistInFolder = documentService.isDocRefExist(document.getDocRef(), RevisionDetailsOption.FOLDER_LEVEL_UNIQUE); // This will check in current folder
boolean isExistInProject = false;
if(!isExistInFolder){
isExistInProject = documentService.isDocRefExist(document.getDocRef(), RevisionDetailsOption.PROJECT_LEVEL_UNIQUE); // This will exclude current folder to check
}
if(isExistInProject){
document.setResponseStatus(false);
document.setResponseMessage(document.getDocRef() + " : DocRef already exist in other folder of the project, please update it.");
}
return document;
}