I'm working on a transition to automatically set the assignee for an issue based on one of our custom fields, and I'm running into a strange issue: while the history for the issue claims that the assignee has changed after the transition finishes, the actual assignee listed on the issue view remains Unassigned. The script in question follows:
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.CustomFieldManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.component.ComponentAccessor; CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField customField_name = customFieldManager.getCustomFieldObjectByName( "Marketing Team" ); def issueService = ComponentAccessor.getIssueService(); def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); if (issue.getCustomFieldValue(customField_name).toString() == 'Affiliate') { def assigned_to = ComponentAccessor.getUserUtil().getUserByName('userone'); def validateAssignResult = issueService.validateAssign(user, issue.id, assigned_to.getKey()); issueService.assign(assigned_to, validateAssignResult); } else if (issue.getCustomFieldValue(customField_name).toString() == 'DM: Ad Buy' || issue.getCustomFieldValue(customField_name).toString() == 'DM: Ad Sales') { def assigned_to = ComponentAccessor.getUserUtil().getUserByName('usertwo'); def validateAssignResult = issueService.validateAssign(user, issue.id, assigned_to.getKey()); issueService.assign(assigned_to, validateAssignResult); }
Having been over every related question I could find:
So with all that said: does anyone have any idea at all what I may be missing to have this work?
Community moderators have prevented the ability to post new answers.
This is the same as this question: https://answers.atlassian.com/questions/31661190
You said you've tried it, but can you retry it, then if it doesn't work post the new code?
Please help....i have script, script is first post function
The assigned user is displayed in the assign field after the transition, but it is not active-is displayed with a "?"
from com.atlassian.jira.component import ComponentAccessor
from com.atlassian.jira.issue import CustomFieldManager
from com.atlassian.crowd.embedded.api import User
from com.atlassian.jira.issue import Issue
from com.atlassian.jira.issue import MutableIssue
from com.atlassian.jira.issue import IssueManager
from com.atlassian.jira.security.groups import GroupManager
from com.atlassian.jira.security.roles.actor import UserRoleActorFactory
issueManager = ComponentAccessor.getIssueManager()
customFieldManager = ComponentAccessor.getCustomFieldManager()
customField = customFieldManager.getCustomFieldObject("customfield_10100")
Is1 = issue.getCustomFieldValue(customField).getValue()
Ur_dit = ComponentAccessor.getGroupManager().getUserNamesInGroup("K2_ABIS")
issue.setAssigneeId('Kur2')
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Dmitriy Kalabin what plugin are you using to execute the above script?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, moving the script to the bottom of the transition list didn't work...but using issue.setAssigneeId at the top did this time! The only difference I can see is that I was getting a mutableIssue object and using that to do the setting, rather than the direct call you listed in the other question. In any case, I don't know how my searching never turned up the other question before, but that did the trick. Much appreciated.
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.