Skip to main content
Groovy Script - Access Current User
Updated over a week ago

Description: Sample groovy script to access current user

Context: Document

Remark: Accessible in 'Pre' task mode only

Script:

def execute(){

// Script to fetch document detail

DocumentVO document = documentService.getDocumentDetails();

// Script to fetch logged in user’s detail

UserVO user = documentService.getCurrentUserDetails();

//Define required details of logged in user from below list

String currentUserEmail = user.getEmail();

String firstName = user.getFname();

String lastName = user.getLname();

String languageID = user.getLanguageId();

String organizationName = user.getOrgName();

String timeZoneId = user.getTimeZoneId();

// Define pre-condition. Here below example represents, when file is being published, system will check logged in user’s email id and Purpose of issue of the document.

if (currentUserEmail.equals("user1@example.com") && document.getPurposeOfIssue().equals("Finance Approved") ) {

document.setResponseStatus(false);

// Define failed message. In above example when mentioned email id and POI will not match then below message will display to user.

document.setResponseMessage("You are not authorized to use this POI, please change.");

}

return document;

}



Did this answer your question?