Hello together,
I used the example from https://scriptrunner.adaptavist.com/latest/jira/fragments/WebPanel.html to add a custom field with its value to Jira in a custom web panel.
That works quite good and the RendererManager is used to render the content correct.
But the field value is currently read only. The default fields from Jira have a "pen symbol" after the value to edit the value directly. Is it possible to generate an editable field within the web panel created with ScriptRunner?
Thanks for your help and best regards
Philipp
I have now found a solution myself, for your information if someone else can use it:
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.RendererManagerdef issue = context.issue as IssueString customfield = "customfield_13923"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("<div id='" + customfield + "-val' class='field-ignore-highlight editable-field inactive' title='Click to edit'>" + "<div class='user-content-block'>" +renderer.render(value, issue.getIssueRenderContext()) +"</div>" + "</div>")
See also: https://community.atlassian.com/t5/Answers-Developer-Questions/How-do-I-enable-inline-editing-on-fields-in-custom-web-panels/qaq-p/501812
Update 2020-06-16: issue.getIssueRenderContext() added as render context (instead of null).
This doesn't work for me unless the field is on the edit screen for the issue, is that what you're doing here? I'd really like to make this work without requiring the field be on the edit screen, but I can't figure out where to begin with the javascript that seems to be required to do so.
Hi mattdgray,
You are right. The field must be configured to be viewable at least for the "create issue" / "edit issue" operation ("view issue" works probably as well).
If the field is not visible in the "edit issue" screen, you will not be able to enter any data to the field because Jira default behaviour is to hide empty fields in the "view issue" screen.
Nevertheless if you will find a solution, please let me know it here.
I can't picture why you want to display the value of a custom field in a web panel. I'm interested to see a screenshot of the output.
It looks like you're new here. Sign in or register to get started.