Hello all! I am brand new to JIRA and have been presented with the following requirement for a test case workflow:
A lead developer is assigned an issue as default in step 2 via a workflow post function. This lead developer assigns it to a member of his team to test in this step. The tester completes their step (step 2) and sends the case for review, deferment, upgrade or what have you. At some later step (3, 8 or 10) we need to assign the issue back to the tester (not lead developer) as default assignee via a script in the workflow post function.
I would appreciate any assistance in showing me how to write this script.
Hi,
I think you could do it like this:
add a user custom field which is named tester
when lead developer assigns the issue to the tester , in the post function sets the value to tester user
or when the tester completes his step in post function , set this field with the username of the tester
and when you need to assign the issue back to the tester, you have just to set value of assignee with tester custom field value in the post function
You can do this using a scripting plugin like power script or script runner or with java Script which is not recommended.
Good luck
Hi zezeto,
Thanks for your advice. I have added the new custom field called "LR Tester" and defined it as a single user picker. I then found the following code (below) and adapted it to fit my needs. In the Post Function script checker, I don't get any errors, but when I run through the work flow, it does not copy the value to the LR Tester field and I can see that my script errored out.
The script is as follows:
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.component.ComponentAccessor
def issue = event.issue as Issue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def tgtField = customFieldManager.getCustomFieldObjects(event.issue).find {it.name == "LR Tester"}
def assignee = issue.assignee
def changeHolder = new DefaultIssueChangeHolder()
tgtField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(tgtField), assignee),changeHolder)
Any thoughts on where I went wrong?
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.
Rather than writing a script this is probably better handled with post functions. There are numerous great plugins that would be able to help you with this. In particular the "JIRA Suite Utilities" plugin allows you to copy values between fields. If you set a user picker field of "tester" this can then be accessed by these post functions to copy the value of that user picker back into the "Assignee" field.
This would probably save you a lot of time.
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.