Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script Runner: Adding lozenge to HTML scripted field to show linked issue status. Edited

What I've done so far all seems to be working well:

  1. I started with this Adaptavist tutorial (with near zero scripting experience).
  2. Added in some custom field values.
  3. Added in an if statement to only list linked issues of a certain type

What is left is that I want to replace my 'Disposition' column with the lozenge instead of the plain text status.

What the table currently publishes as:

table.PNG

 

What I'd like to appear in the last column:

lozenges.PNG

 

Additionally, I'd like to have them not truncated.

An alternative solution I'd also be open to (if it is easier to implement) is to add another column that uses the getStatusCategory() to simply list the To Do/In Progress/Done status lozenge and have the disposition remain as plain text.

The current code:


import com.atlassian.jira.component.ComponentAccessor
import groovy.xml.MarkupBuilder
import org.apache.log4j.Logger
import org.apache.log4j.Level

def log = Logger.getLogger("com.DRTable.GenerateTable")
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def links = issueLinkManager.getOutwardLinks(issue.id)
def customFieldManager = ComponentAccessor.getCustomFieldManager()

log.setLevel(Level.DEBUG)

def writer = new StringWriter()
def xml = new MarkupBuilder(writer)

if(!links){
return null
}

xml.style(type:"text/css",
'''
#scriptField, #ScriptField *{
border: 1px solid black;
}

#scriptfield{
border-collapse: collapse;
}
th {text-align:center
}
td {
padding: 10px;
}
tr:nth-child(even) {
background-color: #eee;
}
tr:nth-child(odd) {
background-color: #fff;
}
''')

xml.table(id:"scriptField"){
tr{
th("Identity")
th("Type")
th("Catagory")
th("Severity")
th("Summary")
th("Disposition")
}
links.each {issueLink ->
def linkedIssue = issueLink.destinationObject
def issueID = linkedIssue.id
def cfType = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Comment Type'}
def cfSeverity = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Severity'}
def cfCategorization = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Categorization'}
log.debug issueID
log.debug linkedIssue.issueTypeId
log.debug linkedIssue.status
if(linkedIssue.issueTypeId == "10410"){
tr{
td(linkedIssue.key.toString())
td(linkedIssue.getCustomFieldValue(cfType))
td(linkedIssue.getCustomFieldValue(cfCategorization))
td(linkedIssue.getCustomFieldValue(cfSeverity))
td(linkedIssue.summary.toString())
td(linkedIssue.status.getName().toString())
}
}}
}

return (writer.toString())

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

273 views 2 5
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you