Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Show Scripted Field on Transition Screen

DerekWilliamsGenscape
January 18, 2018

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>"

 

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Jia Jie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
January 30, 2021

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. 

TAGS
AUG Leaders

Atlassian Community Events