Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner post function: assign user based on two custom fields,

*** JIRA Version 7+ ***

I am trying to determine how to use Scriptrunner to set the assignee during a transition, using a post function, where several separate custom fields impact who the assignee will be.

The first thing that needs to happen is that a single-select drop-down custom field is checked to determine its value (e.g. Option A, Option B, Option C, Option D). 

  • Let's call this cfDropDown.

Next, a checkbox custom field is used to determine if it has a value or is null.

  • Let's call this cfCheckBox.

Next, a single-select entry text field is used to determine what its value is (e.g. 1, 2, or null).

  • Let's call this cfSingleEntry.

Finally, a mapping occurs between that field value and other custom fields. For example,

  • IF cfDropDown = "Option A" AND cfCheckBox = "2" AND cfSingleEntry = "Dogs" THEN assign the issue to the value of a custom User Picker field called "Engineer"
  • IF cfDropDown = "Option A" AND cfCheckBox = "null" AND cfSingleEntry = "Cats" THEN assign the issue to the value of a custom User Picker field called "Artist"
  • IF cfDropDown = "Option C" AND cfCheckBox = "2" AND cfSingleEntry = "null" THEN assign the issue to the value of a custom User Picker field called "Mechanic"
  • etc.
  • etc.

I hope this makes sense, and thank you in advance for your support!


1 answer

Here is an example I wrote up that should demonstrate all the steps necessary. Use it as a template script for your post-function and modify it to suit your needs.

import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.customFieldManager

def cfDropDown = customFieldManager.getCustomFieldObjectsByName("cfDropDown")[0]
def cfArtist = customFieldManager.getCustomFieldObjectsByName("cfArtist")[0]
def cfEngineer = customFieldManager.getCustomFieldObjectsByName("cfEngineer")[0]

def cfDropDownValue = issue.getCustomFieldValue(cfDropDown)
def cfEngineerValue = issue.getCustomFieldValue(cfEngineer)
def cfArtistValue = issue.getCustomFieldValue(cfArtist)

if (cfDropDownValue.value == "Option A") {
} else if (cfDropDownValue.value == "Option B") {

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Staying organized with Jira: best practices for a better project management

Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...

277 views 2 1
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you