Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,553,337
Community Members
 
Community Events
184
Community Groups

How to prepopulate component field on create issue with scriptrunner behaviour

Edited

Can anyone provide a code snippet how to prepopulate the compontent field on create issue.

Adding templates to description fields works fine but a slightly adapted code for components does not work.

def comp = getFieldById("component")
def componentValue = "myComponent"
if (!comp.formValue) {
    comp.setFormValue(componentValue)
}
Any help is welcome
Peter

2 answers

2 accepted

Hi Peter, 

This is Olly from Adaptavist's ScriptRunner Support!

The reason this isn't working, is because you are using underlyingIssue on Create, which doesn't work due to underlyingIssue being null on Issue Creation.

To achieve your requirement, you simply need to:

1. Ensure that the Component you want to add to the Issue with the Behaviour already exists.

2. Add the following code to the Initialiser:

//check if the Issue operation is Create
if
(actionName.equals("Create") ){

//retrieve the Component field, and populate with an existing Component
getFieldByName("Component/s").setFormValue("Example Component")

}

Hope this answers your question!

Thanks,

Olly

Hi Olly

saw your comment too late and got it working myself. Nevertheless your background information is useful for the future.

Thanks a lot,

Peter

0 votes
Answer accepted

The id for Component/s is "components"

 

def comp = getFieldById("components")


if (!comp.formValue) {
    comp.setFormValue("my component")
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events