Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Validate Doc Ref Uniqueness at the Project Level for the First Revision or Issue Only

Groovy Script - Validate Doc Ref Uniqueness at the Project Level for the First Revision or Issue Only

Updated over 3 weeks ago

Description: Sample Groovy script to validate document reference uniqueness at the project level for the first revision or issue only.

Context: Document

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;

}



Did this answer your question?