Hi,
I have a simple behavior to clear the value of a selection field when the user selects No in another field, and the behavior does not work in the JSD portal. In the Jira UI works perfect (the selection list field value is cleared when the user selects No in another field), but in JSD portal just does not work. I have the proper mappings, so I have no clue why it does not work in JSD portal. Here is the server side script:
def SelectionListField = getFieldByName("List A")
def YesNoField = getFieldById(getFieldChanged())
def selectedOption = YesNoField.getValue() as String
def isYesSelected = selectedOption == "Yes"
SelectionListField.setHidden(! isYesSelected)
SelectionListField.setRequired(isYesSelected)
//clear SelectionListField value when YesNoField is No
if (!isYesSelected){
SelectionListField.setFormValue("")
}
I also tried this but it did not work:
SelectionListField.setFormValue(null)
And also tried this but it did not work either:
def optionsMap = ["-1": "None"]
SelectionListField.setFieldOptions(optionsMap)
As I said, in JIRA UI works fine but not in JSD portal.
Any ideas?
Thank you
Hi,
Try: getFieldByName("List A").setFormValue(-1)
Cheers,
Marina
This may be an old issue but it pops up whenever I'm searching for the answer for this, so I'll record my findings here.
Bad Error - causes things to stay in GC
WARN jordan.hauser 853x3046576x1 1fxhefm 10.0.4.185,127.0.0.1 /browse/PR-5018 [c.atlassian.ozymandias.SafePluginPointAccess] Unable to run plugin code because of 'java.lang.NullPointerException - null'.
And in my experience from when I was first trying to figure it out, it leaves stuff in the garbage collector and WILL bring down your server even with ~150 people on it. On certain forms we have multiple tabs for individual line items, and needed some way to mass clear the line items.
Ok Error? - Doesn't appear to affect the GC
2022-09-29 14:13:51,555-0400 http-nio-8080-exec-14 url: /rest/scriptrunner/behaviours/latest/validatorsByPid.json; user: jordan.hauser WARN jordan.hauser 853x3046737x1 1fxhefm 10.0.4.185,127.0.0.1 /rest/scriptrunner/behaviours/latest/validatorsByPid.json [c.o.j.groovy.user.FormField] No option found for customfield_11682 with value -1
For text fields - setFormValue("")
For number fields - setFormValue()
For select fields - setFormValue(-1), setFormValue("-1")
The syntax checker in any of the scriptrunner programming interfaces will yell at you for not including a value for that second one, but it does not produce the error and appears to run fine.
-Jordan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
We are on JIRA Server 8.20.2 and setFormValue(null) worked for us.
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.
Hi Tomas,
tty this, it works fine:
myFormField.setFormValue(["-1", "None"])
Cheers,
Andi
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.