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
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.security.roles.ProjectRole
import com.atlassian.jira.security.roles.ProjectRoleActors
import com.atlassian.jira.security.roles.RoleActor
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(issue.getReporter())
log.warn("to see "+PMOAssignee)
if(groupManager.isUserInGroup(issue.reporter?.name, "jira-administrators"))
{
log.warn("true")
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def validateAssignResult = issueService.validateAssign(user, issue.id, PMOAssignee)
log.warn(issue.reporterId)
issueService.assign(user, validateAssignResult)
log.warn("here")
}
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 "issue.store()" still have the same
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.