Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Script function failed on Automation for Jira rule: error: groovy.lang.MissingPropertyException: No

Mouna Hammoudi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 19, 2023

I am using an automation for Jira rule to be executed once the user clicks on a button. I would like to automatically create some linked issues once the user clicks on the button but I receive the following error message:

enter image description here Script function failed on Automation for Jira rule: Script function failed on Automation for Jira rule: UpdateExecutionSummary , file: SuperFeature/rest_superFeatureGenerator.groovy, error: groovy.lang.MissingPropertyException: No such property: issueLinkType for class: SuperFeature.rest_superFeatureGenerator

How can I fix this?

package SuperFeature 

import com.atlassian.jira.bc.project.component.ProjectComponent
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.index.IssueIndexManager
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.event.issue.IssueEventManager
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.link.IssueLinkTypeManager
import com.atlassian.jira.event.issue.link.IssueLinkCreatedEvent
import com.atlassian.jira.event.issue.link.IssueLinkDeletedEvent
import org.apache.log4j.Level
import org.apache.log4j.Logger
import com.atlassian.jira.issue.link.IssueLinkType


def log = Logger.getLogger('atlassian-jira.log')

log.warn("MOUNA: ")

log.warn("MOUNA COMPONENT NUMBERS : "+ issue.getComponents().size())

List<String> componentList = new ArrayList<String>()
def authenticationContext = ComponentAccessor.jiraAuthenticationContext


if (issue.getComponents().size()==0){
    log.warn("MOUNA CAMELIA COMPONENTS")
    issue.update {
    String text= "Issue does not have any components\n"
    setCustomFieldValue('Execution Summary', text)
    }
}else if(issue.getFixVersions().size()==0){
            log.warn("MOUNA CAMELIA VERSIONS")
            issue.update {
                String text= "Issue does not have any fix versions\n"
                setCustomFieldValue('Execution Summary', text)
                }

    
}

else{
            log.warn("MOUNA CAMELIA ELSE")

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

        for(ProjectComponent component : issue.getComponents()) {
                componentList.add(component.getName())
        }

        issue.update {
            String text= "The super feature "+issue+" will be split into "+componentSize+
            " features, one for each component:\n"

            for(String component: componentList){
                text = text +"-"+ component+"\n"; 
            }
            setCustomFieldValue('Execution Summary', text)

}

// Issue issue
def issueManager = ComponentAccessor.issueManager
def issueFactory = ComponentAccessor.issueFactory
def subTaskManager = ComponentAccessor.subTaskManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def userManager = ComponentAccessor.userManager





MutableIssue newIssue= ComponentAccessor.issueFactory.issue

newIssue.setProjectObject(issue.getProjectObject())
newIssue.setSummary("MOUNA CAMELIA")
newIssue.issueTypeId= 19
newIssue.setAssignee(userManager.getUserByName("mouh"))
newIssue.setDescription(issue.getDescription())
                for(String component: componentList){
                    log.warn("MOUNA CAMELIA component"+ component +" NEW ISSUE "+ newIssue)

                     log.warn("MOUNA CAMELIA Component "+ component+" issue.getId() "+ issue.getId()+" issueLinkType "+issueLinkType+" sequence "+ sequence)                
                    issueLinkManager.createIssueLink(issue.getId(), newIssue.getId(), issueLinkType, sequence, authenticationContext.getLoggedInUser())

        }
}

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, mindful member, mindful member badge, atlassian community, community kudos, community giveaway, atlassian swag, community values, empathy and kindness, badge challenge, atlassian learning, community engagement, swag giveaway

Earn a Badge, Win a Prize 🎁

Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!

Start here
AUG Leaders

Atlassian Community Events