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.
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)
}
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.