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){
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
// Defining subtask
def newIssue = issueFactory.getIssue()
newIssue.setParentId(issue.getId())
log.warn("MOUNA CAMELIA issue.getId()"+ issue.getId())
def Long issueLinkType = new Long (19)
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())
log.warn("MOUNA CAMELIA Component "+ component)
issueLinkManager.createIssueLink(issue.getId(), newIssue.getId(), issueLinkType, sequence, authenticationContext.getLoggedInUser())
}
}
Have you confirmed that you do in fact have a link type in your system that has the ID 10001?
how can I know??
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A Jira Administrator can navigate to Jira Settings > Issues > Issue Linking to find the ID for each link type.
Clicking on the Edit option for a link type will show the link type ID in the URL:
https://<baseURL>/secure/admin/EditLinkType!default.jspa?id=10000
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The right ID is 19 and I have used it and it is till not working.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is not the issue linking screen. Notice that the URL you see at the bottom of the screen does not match what I specified.
The URL for the Issue Linking screen that shows all the link types is
https://<your base URL>/secure/admin/ViewLinkTypes!default.jspa
It will look similar to the below screen. You need to click the Edit option next to the link type you are trying to create in your code.
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.