Scriptrunner condition initiater is customer

Jason Whitaker February 17, 2019
I’m trying to write a scriptrunner event listener to run a custom event when the “issue comment” event is fired and a certain condition is met.

The condition I am trying to validate is whether the initiating user of the comment is a customer.

1 answer

0 votes
Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2019

Hi @Jason Whitaker ,

You are reffering for Jira Service Desk Server, right?

Nir Haimov
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 17, 2019

Assuming your answer will be "yes".

Here is the code of how to do it:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

def commentManager = ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(event.issue)

def author = comments.last().authorApplicationUser

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager.class)
def role = projectRoleManager.getProjectRole("Service Desk Customers")

if (projectRoleManager.isUserInProjectRole(author, role, event.issue.getProjectObject())) {
   //Gets here if the author of the comment is customer
   //Write here what you want to do
}

I tested it, and it work.

Like sina rahemi likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events