Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

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

Renee Aper
May 31, 2017

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 = issue.issueType.name

But that didn't work either.  

Any help would be greatly apprciated!

2 answers

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Paul Ingram
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 5, 2019

Make sure you add your behaviour to the Priority field  - and you have the right field ID's

It should look like this

answer.png

0 votes
Tech Devops
August 5, 2019

 

 

TAGS
AUG Leaders

Atlassian Community Events