You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
Can someone review and let me know why this wont work?
import com.atlassian.jira.bc.project.component.ProjectComponent
def desc = getFieldById("description")
def component = getFieldById(getFieldChanged())
def defaultValue = """
*WHAT:* chicken, chicken chicken
*WHY*
""".replaceAll(/ /, '')
for(c in comps){
if(c.getName().contains(“Stuff”)){defaultValue = true}
}
if (! underlyingIssue?.description) {
desc.setFormValue(defaultValue)
}
Perhaps the following will achieve something close to what you expect:
import com.atlassian.jira.bc.project.component.ProjectComponent
def defaultValue = """
*WHAT:* chicken, chicken chicken
*WHY*
""".stripIndent()
if (! underlyingIssue?.description) {
def components = getFieldById(fieldChanged) as List<ProjectComponent>
if(components.any{it.name.contains('Stuff')}){
def desc = getFieldById("description")
desc.setFormValue(defaultValue)
}
}
Hi @Peter-Dave Sheehan . I tried this code. It compiles with no issues, but it does not seem to populate the Description. In the behavior, I have it set to the Component/s field, not the initializer.
If the component of 'Stuff' is selected on the create screen, it should add the defaultValue to the description box, right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Correct, that's what this code is designed to do.
If that's not working for you ( and you are on a server/dc instance) you will need to add some logging and review your jira logs to see what might be happening.
For example:
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.apache.log4j.Level
log.setLevel(Level.INFO) // make sure log level is adequate to view the messages
log.info "Start of behaviour for Component/s field"
def defaultValue = """
*WHAT:* chicken, chicken chicken
*WHY*
""".stripIndent()
if (! underlyingIssue?.description) {
def components = getFieldById(fieldChanged).value as List<ProjectComponent> //I see the original code was missing .value
log.info "component/s field contains ${components.size()} values, checking if any of them contain stuff"
if(components.any{log.info("component name=$it.name");it.name.contains('Stuff')}){
log.info "stuff component found, setting the description field"
def desc = getFieldById("description")
desc.setFormValue(defaultValue)
}
} else {
log.info "an existing issue was detected ($underlyingIssue.key), we won't update the description"
}
log.info "end of behaviour for Component/s field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Peter-Dave Sheehan . This is working now. I did have to make one correction and change:
import com.apache.log4j.Level
to
import org.apache.log4j.Level
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.