Velocity - Checking that the Sender is Part of a User Group

This script can be used to access the sender email address, check if they are a Jira user and then verify if this user is a member of a group. In this example, we are checking if the sender is a Jira user and if they are a member of the group ‘MyUsers’. If the sender is a Jira user and part of the group, then the Custom Field will be populated with the value ‘Yes’. If not, then the Custom Field will be populated with the value ‘No’.

PLEASE NOTE: This code requires that your Jira Users have unique email addresses. If you have more than one user with the same email address, this script will not work as expected.

 

#set($group = "MyUsers") #foreach ($address in $message.getFrom()) #set($user = $jemhUtils.getUserByEmail($address.getAddress())) #if($groupManager.isUserInGroup($user, $group)) Yes #else No #end #end