Add Hyperlinlik to Scripted Field

Krishnanand Nayak
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.
February 4, 2018

I have a field the shows the parent issue key for any issue. I would like to make this field hyperlinked so that, when clicked it opens the parent issue. Here is my current code:

import com.atlassian.jira.issue.Issue;

Issue parentIssue = issue.getParentObject();
def parentIssueKey, issueKey;

if (parentIssue != null) {
parentIssueKey = parentIssue.getKey();
return parentIssueKey;
}
else {
issueKey = issue.getKey();
return issueKey;
}

 

1 answer

1 accepted

0 votes
Answer accepted
Ivan Tovbin
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.
February 4, 2018

Hi Krishnanand,

Here's how you do it:

1) Make sure your scripted field is using HTML template

2) Make your code return something like this:

return "<a href = \"\">${issueKey}</a>".toString()
Krishnanand Nayak
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.
February 4, 2018

Thanks it helped convert into an hyperlink, but the link when clicked just shows "

https://myjira.com/issues/

I know, there is something obvious that I am missing here.

Ivan Tovbin
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.
February 4, 2018

It works for me just fine. Can you show us your code?

Ivan Tovbin
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.
February 4, 2018

Sorry, my mistake, posted the wrong code, doh!

It should be like this:

return "<a href = \"https://yourjira.com/browse/${issue.getKey()}\">${issue.getKey()}</a>".toString()
Krishnanand Nayak
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.
February 4, 2018

This is what is was missing ... thanks

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events