Skip to main content
Groovy Script - Assign Visibility
Updated this week

Description: Sample groovy script to assign visibility for users, roles and distribution groups only.

Context: Document

Remark: Accessible in 'Post' task mode only

Script:

def execute() {

DocumentVO document = documentService.getDocumentDetails();

// Add roles

def roles = new ArrayList<>();

roles.add("Workspace - Administrator");

// Add groups

def group = new ArrayList<>();

group.add("Doc AAA");

// Add user emails

def user = new ArrayList<>();

user.add("abc@example.com");

Map<String, List<String>> visibilityMap = new HashMap<>();

visibilityMap.put(Recipient.ROLE, roles);

visibilityMap.put(Recipient.GROUP, group);

visibilityMap.put(Recipient.USER, user);

documentService.assignVisibility(document, visibilityMap);

}



Did this answer your question?