You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I would like to create a new linked issue of type feature for a super feature issue. Here is my code:
void createFeature(Issue issue, List<String> componentList){
// Issue issue
//def issueManager = ComponentAccessor.issueManager
//def issueFactory = ComponentAccessor.issueFactory
def issueLinkManager = ComponentAccessor.issueLinkManager
//def userManager = ComponentAccessor.userManager
def authenticationContext = ComponentAccessor.jiraAuthenticationContext
def issueFactory = ComponentAccessor.getIssueFactory()
def issueManager = ComponentAccessor.getIssueManager()
def userManager = ComponentAccessor.getUserUtil()
def currentUserObj = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
MutableIssue newIssue= ComponentAccessor.issueFactory.issue
newIssue.setProjectObject(issue.getProjectObject())
newIssue.setSummary("MOUNA CAMELIA")
newIssue.setIssueTypeId("19")
int issueLinkType= 10070
long sequence =1
long newissueTypeID= 19
long myissueID= issue.getId()
MutableIssue newissue
newissue = issueFactory.getIssue()
//set values
newissue.setProjectObject(issue.projectObject)
newissue.setIssueTypeId("19")
newissue.setSummary("MOUNA CAMELIA")
newissue.setDescription("MOUNA CAMELIA")
newissue.reporter = issue.getReporter()
def newIssueCreated = issueManager.createIssueObject(currentUserObj, newissue)
newIssue.setDescription(issue.getDescription())
for(String component: componentList){
log.warn("MOUNA CAMELIA component"+ component +" NEW ISSUE "+ newIssue)
log.warn("MOUNA CAMELIA Component ====="+ component+"===== myissueID ====="+ myissueID+" =====newissueTypeID ====="+newissueTypeID +" =====issueLinkType ====="+issueLinkType
+" =====sequence ====="+ sequence +" =====authenticationContext.getLoggedInUser() ====="+authenticationContext.getLoggedInUser()+" newIssue.getId() "+newIssue.getId())
issueLinkManager.createIssueLink(myissueID, newIssue.getId(), issueLinkType, sequence, authenticationContext.getLoggedInUser())
}
}
I am using this code block to create a new issue
MutableIssue newIssue= ComponentAccessor.issueFactory.issue
newIssue.setProjectObject(issue.getProjectObject())
newIssue.setSummary("MOUNA CAMELIA")
newIssue.setIssueTypeId("19")
int issueLinkType= 10070
long sequence =1
long newissueTypeID= 19
long myissueID= issue.getId()
then I am using this linke to assign the new issue as a linkedissue:
issueLinkManager.createIssueLink(myissueID, newIssue.getId(), issueLinkType, sequence, authenticationContext.getLoggedInUser())
The function CreateIssueLink
is helping assign the new issue as a linked issue. Here is the API I am using:
The problem is that I get a null pointer exception because newIssue.getId() is null but I cannot assign an ID myselt to the new issue. How can I get the ID and have it automatically generated by Jira so I can avoid the nullpointerexception?
Hi,
After you set all the issue data try to use this method to store the data in Jira
Then you should be able to get the issue ID.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.