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

Setting System Field Defaults Not Loading - Scriptrunner Behaviours Edited

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 Community Leader Jul 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)
}

bueller

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!

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?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

303 views 1 3
Join discussion

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