Setting System Field Defaults Not Loading - Scriptrunner Behaviours

Ryot July 5, 2018

So i'm trying to follow the prebuilt script for setting a system field defaults thats included in the adaptavist knowledge base (original located here). I'm trying to set the component, so I removed the Affects Versions and Assignee portion.

 

I've got it set up in the initializer and it seems to be giving me the green light, but nothing is being selected when I create an issue. Here's the exact script I'm using.

 

import com.atlassian.jira.component.ComponentAccessor

import static com.atlassian.jira.issue.IssueFieldConstants.*

if (getActionName() != "Create Issue") {
return
}


def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(issueContext.projectObject.id)
getFieldById(COMPONENTS).setFormValue(components.findAll { it.name in ["test1"] }*.id)


Note that I'm very new to scriptrunner and the JIRA API components so it could be something super simple I'm missing.

I did confirm the component exists with correct spelling as well.


Here's the screenshot of the setup, too.
Screen Shot 2018-07-05 at 12.48.43 PM.png

3 answers

1 accepted

1 vote
Answer accepted
Mark Markov
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.
July 19, 2018

Hello @Ryot

Try to use this

import com.atlassian.jira.component.ComponentAccessor
import static com.atlassian.jira.issue.IssueFieldConstants.*

if (getAction().id == 1) {
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(issueContext.projectObject.id)
getFieldById(COMPONENTS).setFormValue(components.findAll { it.name in ["test1"] }*.id)
}
0 votes
Ryot July 23, 2018

I ended up going with a feature  used in the JIRA Automations Lite add-on to complete this in a simpler way, but looks like a quick test shows marks stuff should work too!

Jacin Ferreira October 22, 2019

Hi @Ryot I'm playing with JIRA Automations Lite to do this and the only trigger I can find is "Issue created".. but that will change the field after the issue is already filled out.

Did you figure out how to pre-populate the Description or any system field so that it appears when the window to create an issue appears?

0 votes
Ryot July 11, 2018

bueller

Suggest an answer

Log in or Sign up to answer