Hi...I have an script to display the issue key of the parent of a sub-task in issue navigator but I might be missing something since it is not displaying the parent issue key properly. This is the script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.properties.APKeys
import com.atlassian.jira.issue.Issue
def parentkey = issue.getParentObject().getKey()
def baseUrl = ComponentAccessor.getApplicationProperties().getString(APKeys.JIRA_BASEURL)
return (issue.parent != null) ? "<a href=\""+ baseUrl + "/browse/"+ parentkey + "<code>" + parentkey + "</code>" + "</a>" : "";
And this is what I am getting (and I want to get KANBAN-15 instead):
<a href="https://sbjira.dtveng.net/browse/KANBAN-15<code>KANBAN-15</code></a>
I definitely need some help in the last line of the script (the return line)...I am getting a yellow warning but I dont understand the format....can you please help with the last line (I know I am missing something there)...thanks
return (issue.parent != null) ? "<a href=\""+ baseUrl + "/browse/"+ parentkey + "<code>" + parentkey + "</code>" + "</a>" : "";
The code you have here is not just for displaying the parent, it's for displaying it as a linkable item, so when it is clicked, you go to the parent.
I am not 100% sure what you really want from your question, but there are two strong possibilities:
1. When you say you want to see just KANBAN-15, then you don't need all the code for working out the url to link it to. You can cut the code down to one line:
return issue.getParentObject().getKey()
2. You do want to show it as a link. The code you have is fine, but the script field is displaying plain text, so you get it as text. Go to the script definition and look for the "output template". Change it from "text" to "html". That will make JIRA send it to your browser as a link.
Hi Nic...thank you for your answer.
What I want is to display it as a linkable item, so it is option 2. I had set the template to html before asking the question here and it does not do it.
The pic above is the message I am getting when editing the script. It is suggesting a specific format. I think I am missing the closing " or something else. I am not sure about <code> </code> either
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I skimmed the html as it looked like you had copied and pasted a working script and set the template incorrectly.
You are right about the output being slightly wrong. You're missing a closing " and yes, you can lose the <code> bit. i.e.
<a href="https://sbjira.dtveng.net/browse/KANBAN-15<code>KANBAN-15</code></a>
should be
<a href="https://sbjira.dtveng.net/browse/KANBAN-15">KANBAN-15</a>
I think you need :
"<a href=\""+ baseUrl + "/browse/"+ parentkey + "">" + parentkey + "</a>" ;
That should get you closer, but please check it or try it carefully, as I struggle with escaping characters correctly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nic....I got the last line of the script as:
return "<a href=\""+ baseUrl + "/browse/"+ parentkey + "\">"+ parentkey + "</a>"
but still I am getting the whole string in the Issue Navigator
<a href="https://sbjira.dtveng.net/browse/KANBAN-15">KANBAN-15</a>
Thats the same format as you said, but still it is showing the whole text and not the link.
Thank you for your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.