Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,458,992
Community Members
 
Community Events
176
Community Groups

scriptrunner behavior to clear the value of a selection list field does not work in JSD portal

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

4 answers

1 accepted

1 vote
Answer accepted

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

We are on JIRA Server 8.20.2 and setFormValue(null) worked for us.

However, for our JIRA Server 8.4.1, setFormValue(-1) worked.

Hi Tomas,

tty this, it works fine:

myFormField.setFormValue(["-1", "None"])

Cheers,

Andi

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events