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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

How to set a custom field value with Script Runner on Create using other custom field valu


My apologies if I'm not posting in the correct place.

I have an inline Script Runner post function that works perfectly on a subsequent transition, but does not work on the create transition.

It takes the value from a custom field (Support Queue) and uses that to generate the user group to select from a single select list.

import com.atlassian.jira.component.ComponentAccessor
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupManager = ComponentAccessor.getGroupManager()

def queueCf = customFieldManager.getCustomFieldObjectByName("Support Queue")
String qname = issue.getCustomFieldValue(queueCf) 

def singleGroupCf = customFieldManager.getCustomFieldObjectByName("Notify Group")

def group = groupManager.getGroup("Notify " + qname)

issue.setCustomFieldValue(singleGroupCf, [group])

It is working correctly on my "Escalate" transition, but not working on the create transition.  On Create, nothing is populated in the "Notify Group" field.

I am thinking maybe something is not available on create that is available in later transitions?

On create, I actually copy the issue type name into the "Support Queue" field, This is done in a post function prior to the script post function.

If need to use "Issue Type" instead of the custom field to find the name, that would be good too.  

I tried 

String qname =

But that didn't work either.  

Any help would be greatly apprciated!

3 answers

For reference:
There is a -- script-only -- solution to this problem in this other question:

What I ended up using was something like:

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue

def now = (new Date()).toTimestamp() // value to use depends on custom field type
def modifiedValue = new ModifiedValue(null, now)
dateCf.updateValue(null, issue, modifiedValue, new DefaultIssueChangeHolder())
ComponentAccessor.issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false /*sendMail*/)

(and put it just after 'issue created' postfuntion.)


But all credit goes to @JamieA  ;)

I have tried moving my post function to just about every position, and could not get my custom field to to take the value.

I did think of a different approach that worked though. I created a scripted field that takes the value from "issuetype" and puts "Notify " in front of it.

Then, added a post function to copy the value of one field to another. Copy My scripted field into "Notify Group", and it works like a charm.

Thanks for the help - it's great to have some input from other when you are totally stuck!

0 votes
Marc Minten _EVS_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 02, 2017

I do more or less the same things. Two remarks:

(1) is your Post Function placed before the "Creates the issue originally" function ?

(2) I use (I think you should, but I do not understand why it works in your "Escalate" transition) a MutableIssue  type to update the contents of issues:

import com.atlassian.jira.issue.MutableIssue
MutableIssue mutableIssue = issue
mutableIssue.setCustomFieldValue (singleGroupCf, [ group ])

Give this a try ?


I updated both transitions (create and escalate) 

It still works on the Escalate transition, but not on the create transition.

Here's the list of post functions on each:



Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events