Hi All,
i have jira app (data center) Jira Data Center 9.12 and Scriptrunner 8.17.0 installed.
A cutom text field "Other" is created
A select list(single choice) "Impacted Technology" which have many option inside it "IOS,Hybrid,Android,Other"
The purpose is that when the option Other is selected from the list from the issue already created before, the text field other will be shown under the select list and should be mandatory
I have created a behaviour in Scriptrunner mapping to all projects, the affected field is "Impacted Technology" and the script inside the behaviour is the below
Either of your scripts should work.
When you disable the behaviour, do you see the text field? If not, then maybe you forgot to add it to the screen in the first place (or it's not included in your project's field config or in the custom field context).
You can further simplify the script with this:
// Get the value of the custom select list
def selectListField = getFieldByName('Impacted Technology')
def selectedOption = selectListField.getValue()
// Get the text field
def textField = getFieldByName('Other')
// Set the text field properties based on the selected option
def showField = selectedOption == "Other"
textField.setHidden(!showField).setRequired(showField)
You can also add something like this to check whether the selectList field change was detected
selectListField.setHelpText("Debug: field was changed to $selectedOption")
If you don't see anything on your form, there is something wrong with your behaviour configuration.
Oh wait, I see your mistake...
You have to use "getFieldByName" if you want to specify the field name.
Otherwise, getFieldById expects a field id like "customfield_xxxxx"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Peter,
Thanks for your assistance.It works now.
I have used you code above.
Appreciate that.
Regards,
Michel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Can you please assist for the above issue ?
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I Also tried the below script but also did not work
def textField = getFieldByName("Other")
def selectList = getFieldByName("Impacted Technology")
def selectListValue = selectList.getValue()
if (selectListValue == "Other") {
textField.setHidden(true)
} else {
textField.setHidden(false)
}
Please advise if also another step should be performed on jira App
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.