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

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,559,515
Community Members
 
Community Events
184
Community Groups

Help creating a subtask link to the parent issue

Hi,

     I would like your help in order to know why I am receiving the following error by using the Console on Jira Service Desk on Script Runner APP. 

I am creating a subtask and then link this one the to the parent but I have tried to test several solutions over the web and cannot get the root cause of the error I am getting:

Code: 

//Libraries
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.config.SubTaskManager
import com.atlassian.jira.issue.Issue

//Variables definition
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
Issue parentIssue = issueManager.getIssueObject('Jira-21')
def subTaskSummary = parentIssue.getSummary()
Map params = new HashMap()

MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setSummary(subTaskSummary)
newSubTask.setParentObject(parentIssue)
newSubTask.setReporter(user)
newSubTask.setPriorityId(constantManager.getPriorities().find {
it.getName() == "Low"
}.id)
newSubTask.setProjectObject(parentIssue.getProjectObject())
newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
it.getName() == "Feedback"
}.id)
// Add any other fields you want for the newly created sub task
log.debug("New issue ${newSubTask}")
params.put("issue", newSubTask)
//Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>
Issue subtask = issueManager.createIssueObject(user, params)
ComponentAccessor.subTaskManager.createSubTaskIssueLink(parentIssue, subtask, user)
//subTaskManager.createSubTaskIssueLink(parentIssue, subtask, user)
log.info "Issue with summary ${newSubTask.summary} created"

 

The error I am getting is always:

2020-09-15 21:29:07,228 ERROR [common.UserScriptEndpoint]: ************************************************************************************* 2020-09-15 21:29:07,228 ERROR [common.UserScriptEndpoint]: Script console script failed: java.lang.NullPointerException at com.atlassian.jira.issue.link.DefaultIssueLinkManager.getIssueLink(DefaultIssueLinkManager.java:381) at com.atlassian.jira.issue.link.DefaultIssueLinkManager.createIssueLink(DefaultIssueLinkManager.java:89) at com.atlassian.jira.config.DefaultSubTaskManager.createSubTaskIssueLink(DefaultSubTaskManager.java:443) at com.atlassian.jira.config.SubTaskManager$createSubTaskIssueLink.call(Unknown Source) at Script163.run(Script163.groovy:33)

 

The subtask is being created properly with all values I set but the link is the one that is not working.

I have invested several time looking for solutions but the ones I have tried over the internet are not working. 

Script Runner version: 6.9.1

Jira Server version: 8.8.1

Thank you in advance for your help about it because I am getting at the end of the wall :s

1 answer

Hi Gova, Having the same issue with Script Runner version 6.11.0 and Jira Server version 8.5.6, did you ever get a response or a resolution on this?

Hi Cody!

   No one helped me on this. At the end I just create a custom script that allowed me to accomplish the task.

Let me know if you still have the issue, but I guess you already found a way.

Regards.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events