I am using Script Runner plugin and running a custom script with below code to assign issue to a user based on value of a custom field. Custom field is a single select drop-down with 5 options. I am able to capture the value and condition it but I am unable to assign the issue to user using this script.
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.CustomFieldManager import com.atlassian.jira.issue.fields.CustomField import com.atlassian.jira.ComponentManager CustomFieldManager customFieldManager = ComponentManager.getInstance().getCustomFieldManager(); CustomField cf = customFieldManager.getCustomFieldObject(11849); String value = issue.getCustomFieldValue(cf).toString() System.out.println("Custom field Value: "+ value) if(value == 'Production') { String userName="abc" def userManager = ComponentAccessor.getUserManager() def user = userManager.getUserObject(userName) issue.setAssignee(user) System.out.println("If condition executed") } else { System.out.println("If condition Not executed") }
Log Output for positive use case==>
Custom field Value: Production
If condition executed
[DebugMailListener]: Issue: [#101311] test
[DebugMailListener]: Comment: null
[DebugMailListener]: Change Group: null
[DebugMailListener]: EventTypeId: 1
[DebugMailListener]: Time: Tue Apr 28 11:04:19 EDT 2015
[DebugListener]: DebugListener.issueCreated
[DebugListener]: Issue: [#101311] test
[DebugListener]: Comment: null
[DebugListener]: Change Group: null
[DebugListener]: Event Type: Issue Created
[DebugListener]: Time: Tue Apr 28 11:04:19 EDT 2015
Post Function Order==>
PostFunctionOrder.png
User has the Assignable User Permission.
I have been stuck on this for 2 days, can anynone please guide me?
Thanks!!
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Where I'm at is that this works during a regular transition, but it doesn't work during the create transition.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Put the script to first spot in the post functions and then try again
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.