I have a scripted field for which I need to display on a transition screen. The code will generate a <select> drop down based on another custom field value in the ticket. I am having trouble getting this field to appear on the transition screen.
I have followed this article with no success: https://scriptrunner.adaptavist.com/5.0.4/jira/scripted-fields.html#_displaying_script_fields_in_transition_screens
I know my code is working because the preview of the code is working just fine and displaying how I expect.
...
/*Redacted classes for brevity*/
def CreateOption(String OptionVersion, String OptionId) {
return "<option value=\"${OptionId}\">${OptionVersion}</option>"
}
def CreateSelect(ops) {
def temp = []
ops.each {o -> temp.push(CreateOption(o.Version.toString()))}
return "<select>${temp}</select>"
}
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cField = customFieldManager.getCustomFieldObject("customfield_13154")
def cFieldValue = issue.getCustomFieldValue(cField)
OctopusAction o = new OctopusAction(OctopusServer);
def projName = o.getProjectByName(cFieldValue.toString()).Id;
def releases = o.getAllReleases(projName).Items
def options = []
releases.each{r->
options.push(CreateOption(r.Version.toString(), r.Id.toString()))
}
return "<select>${options}</select>"
Hi Branden,
You can remove the hyphen and the issue number with replaceAll() method. Below is the sample script that applied in Behaviours:
//Get the current issue key to remove its hyphen and the issue number
def test = (underlyingIssue as String).replaceAll(/-.*/,'')
def textField = getFieldByName("Single Text")
//Copy the project key to another field "Single Text"
textField.setFormValue(test)
You can also refer to the community post here: Trim string with ScriptRunner for trimming the string before the '@' and copy that value in another text field in Post Function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.