Update assignee on transition only if another field in the ticket is populated?

I need to update the assignee in tickets as they transition status, but only if another field is populated in the ticket. If that other field is blank, the assignee should stay as is (or if it's easier, I can set the assignee to the reporter, which is the value it will already be anyway).

The post functions in JIRA don't allow this, and the custom functions don't seem to cover it either. It's looking like this is something that a script needs to be written for. I'm fine with that, but couldn't find any examples to go off of when googling... maybe I'm searching with the wrong terminology since I'm not a JIRA expert?

If it helps, here's what I'm trying to do in psuedo code...

on transition from state1 to state2
	if qa_resource field is not null
		assignee = qa_resource
        do nothing, or assignee = reporter if easier

Thanks in advance for any help!


3 answers

1 accepted

This is an extremely common use case for Script Runner... on your transition put the following custom script post-function FIRST:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue

MutableIssue issue = issue

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def qaResourceCf = customFieldManager.getCustomFieldObjectByName("QA Resource")
def qaResource = issue.getCustomFieldValue(qaResourceCf)

if (qaResource) {
else {

(totally untested)



worked like a charm, thanks!

This is a pretty standard use case for the Update issues post function from JIRA Command Line Interface (CLI) which allows you to condition whether or not the update should occur. To set a field to 2 different values based on a couple of conditions, you may need multiple post functions where the conditioning determines which update is going to occur.

I've been wanting to use your CLI tool, but unfortunately the budget I was given for add-ons is $0 (for now anyway). Hopefully we'll be able to buy it in the future.

0 votes
Joseph Pitt Community Champion Jan 08, 2015

You don't say if the new assignee is to be selected by the person making the transition or you want it to be decided inside JIRA somehow. Also, is the 'checked' field already set or being set. If already set you can use a condition on the workflow. If being set you'll need some kind of script. If it is already set you can do this by having 2 transitions. On with the condition of the checked field set and one with it not set. Only one will be visible. For the one with the field set just transition the issue without presenting the assignee field. On the other, present it.

The new assignee is to be decided inside Jira - the new assignee should be set only if the QA Resource field is populated. If the QA Resource field is left blank, the assignee field should be left as is. The 'checked' field is already set, though it's not a required field so it's possible that the field is blank. That's why I need to check - if the field is blank, do nothing, if it's populated, update the asignee to be the user listed in the field. I don't think I can have 2 transitions, because the user should only see one transition to go forward at this point in the workflow, and the assignee should only be updated if the QA Resource field was populated, otherwise it should stay as is.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,719 views 17 21
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you