I want to use Script Runner to copy current Assignee to a custom text field 'Resolved by' using the post function during the last transition, which is resolving the issue. I simply want to be able to report on who resolved the issue.
For some reason this script I have developed doesn't work. I will appreciate any help to get this right.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userCf = customFieldManager.getCustomFieldObjectByName("Resolved by")
def assignee = issue.getAssignee()
issue.setCustomFieldValue(userCf, assignee)
Or you can try this one
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def userCf = customFieldManager.getCustomFieldObjectByName("Resolved by")
def changeHolder = new DefaultIssueChangeHolder()
def oldValue = issue.getCustomFieldValue(textCf2)
def newValue = issue.getAssignee()
userCf.updateValue(null, issue, new ModifiedValue(oldValue, newValue),changeHolder)
I did not test the code, please let us know the result ;)
Thanks
Your solutions did not help me unfortunately. I have come across a few other solutions including this https://community.atlassian.com/t5/Jira-questions/Copy-worklog-to-custom-field/qaq-p/239258 but the task turned out to be too difficult.
I need to give up on this idea for now. Thank you for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please try with adding below line after setCustomFieldValue?
def issueManager = ComponentAccessor.getIssueManager()
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
And please give us more details, are you getting an error?
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.