Skip to main content
All CollectionsSystem TasksWorking with Groovy ScriptsGroovy Script Library
Groovy Script - Fetch the list of Documents by Custom Attribute and Update the Title of all Private Documents from the list

Groovy Script - Fetch the list of Documents by Custom Attribute and Update the Title of all Private Documents from the list

Updated over 3 weeks ago

Description: Sample Groovy script to fetch a list of documents based on custom attribute's value and update the title of all the private documents from the list

Context: Document

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);

}

}

}



Did this answer your question?