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

Web Panel with a custom field value

Hi everyone,

I'm trying to build a script that shows a value of a custom field in a web panel, so far without success. 

Can you give me a help?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.RendererManager

def issue = context.issue as Issue

def rendererManager = ComponentAccessor.getComponent(RendererManager)
def cfm = ComponentAccessor.customFieldManager.getCustomFieldObject("WBS") as String

def fieldLayoutItem = ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem("WBS")
def renderer = rendererManager.getRendererForField(fieldLayoutItem)


if (issue) {
writer.write(renderer.render("${cfm}", null))

}else {
return
}

 

1 answer

For anyone searching, here is the solution:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.RendererManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField

def issue = context.issue as Issue

def rendererManager = ComponentAccessor.getComponent(RendererManager)
def fieldLayoutItem = ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem("WBS")
def renderer = rendererManager.getRendererForField(fieldLayoutItem)

def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_14572")
def cFieldValue = issue.getCustomFieldValue(cField)

if (cFieldValue) {
writer.write(renderer.render("Resolution Time: " + cFieldValue, null))
}

Suggest an answer

Log in or Sign up to answer
TAGS

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