Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Set and store assignee value

Hi all, I'm using the Scriptrunner post function and i'm trying to set the assignee based on a component and custom field. I understand apart from setting the assignee, you'd also need to store that in the DB. (Currently it doesn't change the value of the assignee). Could anyone help with how to store the assignee? Below is what i have so far

import com.atlassian.jira.component.ComponentAccessor

// the username of the assignee
final String user= "user1"

def user_user1 = ComponentAccessor.userManager.getUserByName(user)
def location = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("Location")
def location_val = issue.getCustomFieldValue(location)

if(issue.components*.name.contains('Hardware') && location_val == "Utrecht" ){


2 answers

1 accepted

1 vote
Answer accepted

You do not need to think about storage or indexing, the post-functions on the transition will do all of that for you, as long as you put your post-function in the right order in the list (it should be done before indexing and store issue)

Your code looks mostly ok to me as well, but I suspect there's a fault in the "if".  You are comparing location_val with a string, but that will only work if location_val really is a string.  Is the location field really a short text field? 

Or is it a select list?  If it's a select list, then your "if" is comparing a string with an option, so they're never going to be equal.  I would try

&& "Utrecht".equals(location_val.getName()

If it is not that, then I'd guess that your user does not exist, or your feidls do not have the values you are checking for (or do not exist for the project and issue type)

You're spot on about the if statement. The was the issue as the field that i'm referring to is a select field. I tried your method but it kept giving me errors. I've added this line to get the value from a select field:

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjects(issue).find { == 'Location'}
def cfConfig = cf.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find { it.toString() == 'Utrecht' }

Hi @Filzah Aziz 

Have you taken a look at their library?


Suggest an answer

Log in or Sign up to answer

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