Hi,
In JIRA, I am trying to create a Web Panel which will display the linked epics details in HTML format as below,
Key | Summary | Status | Type | Fix-Version |
JIRAKey-123 | Linked Epic - 1 | New | Epic | [Label-test] |
I referred below sites and did this,
Advanced Scripted Field - https://scriptrunner.adaptavist.com/latest/jira/recipes/misc/table-custom-field.html
Web Panel - https://scriptrunner.adaptavist.com/latest/jira/fragments/WebPanel.html
Here is my code. It doesn't display the content in Issue View screen.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import groovy.xml.MarkupBuilder
Issue issue = context.issue as Issue
//Get current Key
def currKey = issue.getKey()
//Query for all epics where feature link = current key
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def searchProvider = ComponentAccessor.getComponent(SearchProvider)
def issueManager = ComponentAccessor.getIssueManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getUser()
def queryString = 'type=epic and "Feature Link" = ' + currKey
def query = jqlQueryParser.parseQuery(queryString)
def results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
StringWriter writer = new StringWriter()
def xml = new MarkupBuilder(writer)
if(!results){
"N/A"
}
xml.style(type:"text/css",
'''
#scriptField, #scriptField *{
border: 1px solid black;
}
#scriptField{
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: center;
}
''')
xml.table(id:"scriptField"){
tr{
th("Key")
th("Summary")
th("Status")
th("Type")
th("Fix-Version")
}
results.getIssues().each { documentIssue ->
tr{
td(documentIssue.key.toString())
td(documentIssue.summary.toString())
td(documentIssue.status.getName().toString())
td(documentIssue.getIssueType().getName())
td(documentIssue.getFixVersions())
}
}
}
return (writer.toString())
Hence, I tried to display the simple content as a div. I just removed MarkupBuilder part from the above code and wrote it as simple as below.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import groovy.xml.MarkupBuilder
Issue issue = context.issue as Issue
//Get current Key
def currKey = issue.getKey()
writer.write("<div style='background-color: yellow; text-align: center'>" +
" ${currKey} - Testing </div>")
In the second case, it is displaying the web-panel with data correctly as below
Can anyone look into my first code and tell me what i am doing wrong over there? I feel like, this is not working for 'MarkuuBuilder'.
Is there any other way to display the data in a simple and need HTML table.
Please help me out.
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.
Hi,
You can try with Smart Issue Panels for Jira (https://marketplace.atlassian.com/apps/1221267/smart-issue-panels-for-jira)
Cheers
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think you can just use official writer object and give xml markup as string to the write() function
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.