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")
issue.setComponent([newcomponent10])
Environment - Adaptavist ScriptRunner v5.3.5 with JIRA v 7.4.4
Thanks,
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")
issue.setComponent([newcomponent12,newcomponent121])
Thanks!
Wayne
Hi Wayne,
Use this:
def allComponent = issue.getComponent()
def newComponent = hereYourNewComponentif (!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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh, remember to put this post function before the issue update post function or you will need to use updateIssue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cristian,
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.
Wayne
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cristian,
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
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.