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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,690
Community Members
 
Community Events
184
Community Groups

Show custom field in ScriptRunner web panel

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:

Web_panel.png

This is what I get:

Error.png

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

1 answer

0 votes
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Apr 14, 2023

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events