Description: Sample Groovy Script to fetch a list of documents based on a Custom Attribute's value and update the title of all the private documents in the list.
Context: Document
Document Type: File
Remark: Accessible in 'Post' task mode only.
Script:
def execute(){
String attributeName = "AppStatus";
String attributeValue = "Rejected";
String folderPath = "Asite Project\\Documents";
HashMap optionMap = new HashMap<>();
optionMap.put(RevisionDetailsOption.LATEST_REVISION,true);
//optionMap.put(RevisionDetailsOption.ALL_REVISION,true); // if you want all the revisions, use this option instead of above.
List<DocumentVO> documents = documentService.getDocsByCustomAttribute(attributeName, attributeValue, folderPath, optionMap);
for(DocumentVO doc: documents){
if (doc.isPrivate()){
List<String> customAttributeValueList = documentService.getCustomAttributeValue(doc, "App Title");
String appTitle = customAttributeValueList.get(0);
documentContext.getDocVO().docTitle = appTitle;
documentService.updateDocument(documentContext);
}
}
}