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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

Create a new linked issue but new issue ID is null

Edited

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:

Capture.PNG

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?

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.
Sep 25, 2023

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events