It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Change the assign on a post-function to a project role mumber

The Task is on creating issue assign to one of a project roles based on the reporter.

I test this script below in a script console with a given issue I work fine but when I put it in a post-function is not working the assignee did not change.

Can someone help me, this is the code 


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
//import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue


def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()

//def issue = issueManager.getIssueObject("BDI-5")

ProjectRoleManager projectRoleManager = ComponentAccessor.getComponentOfType(ProjectRoleManager.class) as ProjectRoleManager
def groupManager = ComponentAccessor.getGroupManager()

// Get any role
ProjectRole PMOR = projectRoleManager.getProjectRole("Administrators")
ProjectRoleActors PMOActors = projectRoleManager.getProjectRoleActors(PMOR, issue.getProjectObject())
def PMOAssignee = PMOActors.getUsers().toList().first().username

log.warn("to see "+PMOAssignee)

if(groupManager.isUserInGroup(issue.reporter?.name, "jira-administrators"))
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def validateAssignResult = issueService.validateAssign(user,, PMOAssignee)
issueService.assign(user, validateAssignResult)

1 answer

1 accepted

0 votes
Answer accepted

can you show the order of your postfunctions? 

it works finicky on creation iirc, might be you are assigning the issue, and then it applies default rule

so maybe try moving it to the very end of postfunctions list

Hey IIya, 

I changed the post-function to different order still the same, no error found the script working but the assignee did not change, it seems like in post-function he didn't get the current issue I tried also to add this line in the end "" still have the same   

wait, that's no "creating issue"

for regular transition you can just use 

issue.assignee = PMOAssignee

it works because before the issue is stored to database postfunctions are performed on Mutable Issue

the issue is alredy created.

Yeah it's

issue.assigneeId = PMOAssignee
issue.assignee //should take a string 

 Thank you IIlya for you help it works :)

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you