You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hello community,
I want to display an existing custom field in a web panel. I use the “Show a web panel” function from ScriptRunners Script Fragments.
In my case it’s a calculated progress field from the sumUp plugin.
This is what I want:
This is what I get:
I have found an old post in which it says that it’s not possible to display custom fields in a web panel. Maybe that has changed in the meantime.
Maybe (or most likely) there is a bug in my script because I don't know Groovy that well.
This is the script I use:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.RendererManager
def issue = context.issue as Issue
String customfield = "customfield_19800"
def rendererManager = ComponentAccessor.getComponent(RendererManager)
def fieldLayoutItem = ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem(customfield)
def renderer = rendererManager.getRendererForField(fieldLayoutItem)
String value = issue.getCustomFieldValue(ComponentAccessor.getCustomFieldManager().getCustomFieldObject(customfield))
writer.write(renderer.render(value, issue.getIssueRenderContext()))
Best regards,
Jo
I'm not familiar with the SumUp plugin and how it stores its values.
But it would seem that when you return "value" from getCustomFielValue, it returns an object of some kind that doesn't have an automatic "toString" method.
If you're not sure what that value is, you can output its class as a debug step.
writer.write(renderer.render(value.getClass(), issue.getIssueRenderContext()))
Then see if the sumUp plugin has documentation for how to render that class.
If they don't you can use Groovy metaClass to get an idea of what methods that object might have:
writer.write(renderer.render(value.metaClass.methods*.name.sort().unique(), issue.getIssueRenderContext()))
Hello Peter-Dave,
sorry for the late reply. I was on vacation. I will test this with my colleagues.
Best regards,
Jo
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.