Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hello Community users,
I am trying to get the value of the "Parent Link" field using the script runner plugin in an scripted field.
I know there is an open issue about - https://jira.atlassian.com/browse/JPOSERVER-1663
I tried in the script console the following script
def issueManager = ComponentAccessor.getIssueManager(); def issue = issueManager.getIssueObject("XYZ-103"); def customFieldManager = ComponentAccessor.getCustomFieldManager(); def parentLink = customFieldManager.getCustomFieldObjectByName('Parent Link'); def customFieldValue = issue.getCustomFieldValue(parentLink); return customFieldValue
Using this script I see the above output on the screen - "com.atlassian.rm.jpo.env.issues.JiraIssueService" , is there a method which I can use on this class to return the issueKey/issueID of the parent Link ? As I can't seem to find in the public SDK/API documentation of the class JiraIssueService in the JPO package hierarhcy.
Also, another way I can see around this problem is to use JQL search inside the scripted field as the new version of script runner supports portfolio specific functions like "portfolioParentsOf " which can give the parent Link issueKey based on the Epic issueKey.
Please share your opinion.
In case someone else is facing this issue, here's the complete solution -
Basically we can use the below script to display initiative(epic's parent) summary and key in a custom field on the story screen. Basically create a scripted field and add is on story view screen and add the below script to the field and you should see the summary of grand-parent of story type on the story itself.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def epicLink = customFieldManager.getCustomFieldObjectByName('Epic Link');
def parentLink = customFieldManager.getCustomFieldObjectByName('Parent Link');
def epic = issue.getCustomFieldValue(epicLink)
if(epic) { // here we check if the story is connected to an epic
epic = (Issue)epic
if(epic.getCustomFieldValue(parentLink)) { // here we check if epic is connected to an parent (via portfolio)
def parentLinkReference = epic.getCustomFieldValue(parentLink);
def key =(String)parentLinkReference.getKey();
def summary =(String)parentLinkReference.getSummary();
return key.concat(" ").concat(summary)
}
}
return null
You should just be able to do something like this:
import com.atlassian.jira.component.ComponentAccessor def issueManager = ComponentAccessor.getIssueManager(); def issue = issueManager.getIssueObject("XYZ-103"); def customFieldManager = ComponentAccessor.getCustomFieldManager(); def parentLink = customFieldManager.getCustomFieldObjectByName('Parent Link'); def customFieldValue = issue.getCustomFieldValue(parentLink); def parentKey = customFieldValue.key return parentKey
Does that not return the parent's key for you?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Indeed, ".key" returns the issueKey, thanks! From where can I find class definition of "com.atlassian.rm.jpo.env.issues.JiraIssueService" as I ddin't know that it had the getKey() method which returns the issueKey.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That's a good question Tarun. It looks like there is actually no published API for JIRA Portfolio, so I can see how it would be difficult to know what method to use.
I'd follow the issue on Atlassian's board here:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, I am the product manager for an add-on called Power Scripts that lets you create the same type of automation as Script Runner. I know this question was already answered but I just wanted to share some information that might be helpful to others who are not groovy developers and are just looking for a solution to their problem. Instead of trying to copy and paste code you don’t understand then crossing your fingers hoping it works, there is an easier solution.
string parentLink = #{TEST-123.Parent Link}; //get parent link
#{TEST-123.Parent Link} = "TEST-567"; //set parent link
Getting the parent link can be done in one simple line and seems a lot easier than all that mumbojumbo I see above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,use power script get portfolio "Parent Link";
string key = "JIRAGJ-252";
string[] parentIssues = allLinkedIssues(key, "Parent-Child Link", -1);
#exception while executing sil program >> null << sil error on line 7 column 28 null
How can I solve it, thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guyunpen, the best way to get this resolved is to open a support ticket here - https://jira.cprime.io/servicedesk/customer/portal/2. Be sure to attach the entire script to the ticket. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.