I am trying to generate some issue links in jira, here is my code. This code is executed as a Jira automation rule after clicking on a button. The problem is that I receive the following error message. They say that the issuelinktype is wrong, anyone knows how to figure out which issue link type I need?
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.link.IssueLinkManager
import com.atlassian.jira.issue.index.IssueIndexingService
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){
issue.update {
String text= "Issue does not have any components\n"
setCustomFieldValue('Execution Summary', text)
}
}else if(issue.getFixVersions().size()==0){
issue.update {
String text= "Issue does not have any fix versions\n"
setCustomFieldValue('Execution Summary', text)
}
}
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
// Defining subtask
def newIssue = issueFactory.getIssue()
newIssue.setParentId(issue.getId())
log.warn("MOUNA CAMELIA issue.getId()"+ issue.getId())
def Long issueLinkType = new Long (10001)
def Long sequence = new Long (1)
newIssue.setProjectObject(issue.getProjectObject())
newIssue.setSummary("MOUNA CAMELIA")
newIssue.setAssignee(userManager.getUserByName("mouh"))
newIssue.setDescription(issue.getDescription())
for(String component: componentList){
def subTask = issueManager.createIssueObject(authenticationContext.getLoggedInUser(), newIssue)
subTaskManager.createSubTaskIssueLink(issue, subTask, authenticationContext.getLoggedInUser())
issueLinkManager.createIssueLink(issue.getId(), newIssue.getId(), issueLinkType, sequence, authenticationContext.getLoggedInUser())
}
}
MutableIssue newissue= ComponentAccessor.issueFactory.getIssue()
def newIssueCreated = issueManager.createIssueObject(currentUserObj, newissue)
issueLinkManager.createIssueLink(newIssueCreatedID, myissueID, issueLinkType, sequence, authenticationContext.getLoggedInUser())