I followed the method in this wiki page to show a table in script field: https://scriptrunner.adaptavist.com/latest/jira/recipes/misc/table-custom-field.html
but the table just show text. I also want the issue key in the table is a hyperlink to be clicked.
so I tried to return a html format of hyperlink, it can be displayed as a hyperlink
def hyperlink = "<a href=\""+browseurl+issue.key+"\">"+issue+"</a>";
log.info(hyperlink)
return hyperlink
but when I input this information into a table (as code below), it displays as text.
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
log.debug("Total issues: ${results.total}")
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
def browseurl = com.atlassian.jira.component.ComponentAccessor.getApplicationProperties().getString("jira.baseurl")+"/browse/"
if (results.total < 1)
{
xml.string("Nothing required.")
}
else
{
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 ->
log.debug(documentIssue.key)
// if you need a mutable issue you can do:
def issue_i = issueManager.getIssueObject(documentIssue.id)
// do something to the issue...
log.debug(issue_i.key)
//issue_i hyperlink
def ikey = issue_i.key;
def issue_i_link = "<a href=\""+browseurl+ikey+"\" >"+ikey+"</a>";
tr {
td(issue_i_link)
td(issue_i.summary.toString())
td(issue_i.status.getName())
}
}
}
}
return (writer.toString())
what is displayed:
<a href="https://xxx/xx">issue</a>