Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Get parent issue of a sub-task on the Create Issue screen in a ScriptRunner Custom Picker field

Chris Kite
Contributor
March 16, 2023

I have a ScriptRunner Customer Picker field that presents a list of options retrieved from a REST endpoint. This works just fine and the field is used on a few various screens in different projects.

In one of the projects, the field is on a sub-task screen. I want to use information from the parent issue to filter the list on the sub-task Create Issue screen but I cannot figure out how to access the parent issue information. I can't use the standard "issue" context because it's null since the sub-task has not been created yet.

I can access the parent issue information from a ScriptRunner behavior but I can't figure out how to dynamically alter the picker logic. Even if that's possible ideally I'd like to figure out how to do this in the Script Field so that all the logic is contained in one place.

2 answers

2 votes
Fabio Racobaldo _Herzum_
Community Champion
July 5, 2023

Hi @Chris Kite ,

you can retrieve parent issue in create screen through the following code :

import com.atlassian.jira.issue.IssueManager

import com.atlassian.jira.issue.Issue;
...

def parent = getFieldById("parentIssueId");

Long parentIssueId = parent.getFormValue() as Long;

IssueManager issueManager = ComponentAccessor.getIssueManager();

Issue parentIssue = issueManager.getIssueObject(parentIssueId);
Hope this helps,
Fabio
Penn May 6, 2025

Thank you @Fabio Racobaldo _Herzum_ This is spot on 

0 votes
Albert Manuel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2023

Hi,

Tricky one - maybe you can achieve this by passing the parent issue key as a URL parameter when calling the REST endpoint and then using it to filter the results. It's just an ideea

Chris Kite
Contributor
March 20, 2023

I can easily do the filtering via passing by URL parameter, that's not the problem.

The problem is getting the parent issue key when on the sub-task CREATE screen. Since the sub-task does not exist yet so "issue" context is null.

Suggest an answer

Log in or Sign up to answer