Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

How to add multiple Component/s when using script post function to Clone issues.

The following sets a single component, but need to add up to 5 different Components on several of the issues cloned during a script post function.  I searched online and could not find any examples on how to accomplish.

def projectComponentManager10 = ComponentAccessor.getProjectComponentManager()
def newcomponent10= projectComponentManager10.findByComponentName(project10.getId(), "FSU")

Environment - Adaptavist ScriptRunner v5.3.5 with JIRA v 7.4.4


2 answers

1 accepted

0 votes
Answer accepted

Sorry for my delayed update - holiday, year-end vacation, cold, but found a solution that works as needed. Found that defining another selection was all that is needed. While the below example only shows cloning the issue with only 2 Component selection using a Post Function script, I have another with 6.

def projectComponentManager12 = ComponentAccessor.getProjectComponentManager()
def newcomponent12= projectComponentManager12.findByComponentName(project12.getId(), "DPU624VG")
def newcomponent121= projectComponentManager12.findByComponentName(project12.getId(), "DPU648VG")


0 votes

Hi Wayne,

Use this:

def allComponent = issue.getComponent()
def newComponent = hereYourNewComponent

if (!allComponent .contains(newComponent)) {

    allComponent .addAll(newComponent)
    issue.setComponent(allComponent )


With this, you have a variable which has the old values of the component and, if the new component is not in that collection, then it adds the new component.

Oh, remember to put this post function before the issue update post function or you will need to use updateIssue



Thank you for the response, I did try to implement and ran into the "Cannot call <T>" error. I will work to see if I can resolve.





newComponent is a String in that definition you made. You need to use the get component as you did in your script:

def projectComponentManager10 = ComponentAccessor.getProjectComponentManager()
def newcomponent10= projectComponentManager10.findByComponentName(project10.getId(), "FSU")

I recommend to use the Script Console first. In the console you will need a mutable issue as in this example:

import com.atlassian.jira.issue.MutableIssue

def issueManager = ComponentAccesor.getIssueManager()
def issue = issueManager.getIssueObject("XXX-000") as MutableIssue

You can also check logs in the console easier with logs:

log.warn whatYouWantToCheck

Anyway I see you are using the script in the "Aditional issue actions". I guess you are using the create subtasks psot function from scriptrunner. I personally don't like it and create the subtasks with a custom script because it works... weird...



Thank you for the additional direction, I will be able to try this on Monday, Nov 26, after vacation and holiday.

Yes - this is being used as Additional Issue Actions.  Our IT Department is short-staffed  and not able to support JIRA request. The script post function has served adequately, but this will be the biggest script work to date.  I am an engineering program manager, not a developer, so the hope is to get this operational and working and then we can get a software developer resource in the future to move to a custom script.  

Thanks again and will keep you posted

Suggest an answer

Log in or Sign up to answer
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

78 views 0 4
Read article

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