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

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


1 badge earned


Participate in fun challenges

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


Gift kudos to your peers

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


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!


Script function failed on Automation for Jira rule:IllegalArgumentException: wrong number of argumen

I am trying to use the HAPI API for Scriptrunner and I am getting the following error: enter image description here

My code is very simple, I am using the following:

         Collection < ProjectComponent > updatedComponentList = issue.getComponents()

            issue.set {

I have found the syntax under this link:

Here is my whole code if needed:

package SuperFeature

import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import com.atlassian.jira.project.version.Version
import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.bc.project.component.ProjectComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.label.LabelManager
import SuperFeature.Configuration_SuperFeature
import com.adaptavist.hapi.jira.issues.delegate.AbstractIssuesDelegate
def log = Logger.getLogger('atlassian-jira.log')
List < ProjectComponent > finalComponentList = new ArrayList < ProjectComponent > ()

    int componentSize = issue.getComponents().size()

    int generatedIssuesCounter= 0
     for (ProjectComponent component: issue.getComponents()) {
                      String componentName = component.getName()
                    def shortenedComponentName = componentName.substring(componentName.indexOf("-") + 1)
                    def projectName = componentName.substring(0, componentName.indexOf("-"))


                                        def newIssueproject = ComponentAccessor.projectManager.getProjectObjByKey(projectName)

                                        List < ProjectComponent > newList = new ArrayList < > (newIssueproject.getComponents());
                                            def found = newList.any {
                                            if (found) {


    createFeature(issue, finalComponentList)

void createFeature(Issue issue, Collection < ProjectComponent > componentList) {
    JiraAuthenticationContext authenticationContext = ComponentAccessor.getJiraAuthenticationContext();

    long issueLinkType = Configuration_SuperFeature.hierarchyIssueLinkType as long
    long sequence = Configuration_SuperFeature.sequence as long
    long myissueID = issue.getId() as long
    // the key of the project under which the version will get created
    final String projectKey = Configuration_SuperFeature.projectKey 
    // the start date - optional
    final Date startDate = null
    // the release date - optional
    final Date releaseDate = null
    // a description for the new version - optional
    final String description = null
    // id of the version to schedule after the given version object - optional
    final Long scheduleAfterVersion = null
    // true if this is a released version
    final boolean released = false
    def project = ComponentAccessor.projectManager.getProjectObjByKey(projectKey)
    assert project: "Could not find project with key $projectKey"
    ProjectComponentManager projectComponentManager = ComponentAccessor.getProjectComponentManager()

    Collection < ProjectComponent > updatedComponentList = issue.getComponents()
    for (ProjectComponent component: componentList) {

        String componentName = component.getName()
        def shortenedComponentName = componentName.substring(componentName.indexOf("-") + 1)
        def projectName = componentName.substring(0, componentName.indexOf("-"))

        def newIssueproject = ComponentAccessor.projectManager.getProjectObjByKey(projectName)
        List < String > newIssueProjectVersionIDs = new ArrayList < String > ()
        newIssueProjectVersionIDs = newIssueproject.getVersions().collect {

        def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(Configuration_SuperFeature.investmentAreaCustomField); 
        def value = issue.getCustomFieldValue(customField);

         def matchedVersions = issue.getFixVersions().intersect(newIssueproject.getVersions(), Version.NAME_COMPARATOR)

        ProjectComponent newComponent = projectComponentManager.findByComponentName(newIssueproject.getId(), shortenedComponentName)

        def componentArray = new String[1]

        def versionCreator = ComponentAccessor.versionManager.&createVersion.rcurry(startDate, releaseDate, description,, scheduleAfterVersion, released)
        def mynewVersions = issue.fixVersions.intersect(newIssueproject.versions, Version.NAME_COMPARATOR).collect {
            versionCreator + '-Inbox'

        //  long newIssueCreatedID = newissue.getId() as long
        // def labelManager = ComponentAccessor.getComponent(LabelManager)
        // labelManager.addLabel(authenticationContext.getLoggedInUser(), newIssueCreatedID, "SF-Child", false)

        // updatedComponentList.removeAll(component)
        // projectComponentManager.updateIssueProjectComponents(issue, updatedComponentList)
        // issue.setComponents(updatedComponentList)

                //     issue.update {
                //     setComponents(updatedComponentList)
                // }

                issue.set {

        Issue newissue = Issues.create(projectName, 'Feature') {
            setSummary("["+shortenedComponentName+"] "+issue.getSummary())
            setDescription("This feature has been generated as child of a super feature. Please use this text area to add child feature specific information.")
            setCustomFieldValue(customField.getFieldName(), value)
            setFixVersions(mynewVersions as String[])
            setComponents (componentArray as String[])
            setLabels(["SF-Child"] as String [])

      , issue)


1 answer

0 votes
Mohamed Benziane
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Oct 27, 2023


Can you provide the error message, the link seems to be broken

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events