Getting the current user - Groovy
Abstract
This code snippet fetches the user who triggered the current transition.
Logic
This snippet uses the currentUser
built-in variable to fetch the ApplicationUser object representing the user who triggered the current transition.
Snippet
currentUser
Examples
The output of this code snippet is an ApplicationUser object representing the current user which you could use in:
A Groovy template, for example to:
- Set a user picker field to the current user. Eg: Save the user who "coded" an issue into an "Implemented by" custom User Picker field for traceability and reporting purposes or Assign an issue to the current user in
- one of the Set Field Value post-functions
- the Create issue post-function under Set fields of new issue section
Conditionally execute a Post-function/Condition/Validator or Unlink issues - Eg: Check that the current user is the Reporter of the issue
issue.get("reporter") == currentUser
A Groovy template, for example to:
- Notify the customer that the issue raised by them is being handled by the current user through the
- Comment in one of the Comment issue post-functions
Subject/HTML body/Text body of Email issue post-function
Hi <%=issue.get("reporter").getName()%>. Your issue is being handled by <%= currentUser.getDisplayName() %>
Write a JQL search expression in the Link issues to current issue post-function - Eg: Link issues assigned to the current user
assignee = <%= currentUser.getName() %>
References
Related articles