Looking at the example given here https://scriptrunner.adaptavist.com/latest/jira/recipes/misc/table-custom-field.html
This is exactly what I need, but I would love if instead of listing the issuekeys I could list html links to these issues.
In the example the table is made up by adding keys like this:
# td(issue.key.toString())
resulting in something like this
# <td>TEST-4</td>
I would like to have as the result
# <td><a href="https://.../TEST-4>TEST-4</a></td>
But
#
td("<a href=\"https://../browse/${issue.key.toString()}\">${issue.key.toString()}</a>")
does not help..
Any suggestions?
Hi,
Change the scripted field template type from "HTML" to "Text Field (multi-line)"
Copy this exactly to your scripted field and it will work for you.
import com.atlassian.jira.component.ComponentAccessor
def baseurl = ComponentAccessor.getApplicationProperties().getString("jira.baseurl");
"<td><a href='${baseurl}/browse/${issue}'>${issue}</a></td>"
In order to show in a table just add some html as string to the scripted field
Thanks Nir,
I am new to this scripting language, but your answer helped me find the solution.
The final result in my script looks like this (and it seems to work fine):
def mystring = "<html>\n" +
"<head>\n" +
"<style>\n" +
"table, th, td {\n" +
" border: 1px solid black;\n" +
" border-collapse: collapse;\n" +
"}\n" +
"th, td {\n" +
" padding: 5px;\n" +
" text-align: left; \n" +
"}\n" +
"</style>\n" +
"</head>\n" +
"<body>\n" +
"\n" +
"<table>\n" +
" <tr>\n"+
" <th>Issue Key</th>\n" +
" <th>Summary</th>\n" +
" <th>Status</th>\n" +
" </tr>\n"
results.getIssues().each {documentIssue ->
def issue = issueManager.getIssueObject(documentIssue.id)
mystring += " <tr>\n"
mystring += " <td><a href='${baseurl}/browse/${issue.key}'>${issue.key}</a></td>\n"
mystring += " <td>${issue.summary}</td>\n"
mystring += " <td>${issue.status.getName()}</td>\n"
mystring += " </tr>\n"
}
mystring += "</table>\n</body>\n</html>"
return mystring
For reference the code I had (based upon an example) looked like this:
xml.style(type:"text/css",
'''
#scriptField, #scriptField *{
border: 1px solid black;
}
#scriptField{
border-collapse: collapse;
}
''')
xml.table(id:"scriptField"){
tr{
th("Key")
th("Summary")
th("Status")
}
results.getIssues().each {documentIssue ->
def issue = issueManager.getIssueObject(documentIssue.id)
tr{
td(issue.key.toString())
td(issue.summary.toString())
td(issue.status.getName().toString())
}
}
}
return (writer.toString())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Nir Haimov : Do you know if I can use a similar script to create a field to display a filter as a link? What I really want is to display specific filters as link on my dashboard. (Similar to what fav filter gadget already does: except that this is not all my fav filter)..
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.