Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

×
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

Setting custom field options in behaviour

Edited
Artemy Matvienko
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 Leaders.
Mar 07, 2019

I have the following code. I'm trying to only show custom field options that match a certain filter.

def customField = customFieldManager.getCustomFieldObject(cfield.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)

def filter = "(test1/test2, test)";
def filterOptions = options.findAll { it.value.contains(filter) }

cfield.setFieldOptions(filterOptions )

The problem I have is that when I print out the "options" variable, it shows a set of options in the format of "key:value". However, when I print out "filterOptions", it shows a list in the format of "value".

I'm also getting the following error that I think is related to this observation:

/rest/scriptrunner/latest/canned/com.onresolve.scriptrunner.canned.common.StaticCompilationChecker [c.o.s.canned.common.StaticCompilationChecker] Type checking error: com.atlassian.cache.CacheException: java.lang.NullPointerException: Null keys are not supported
com.atlassian.cache.CacheException: java.lang.NullPointerException: Null keys are not supported

I've tried examples from here. Namely the following two: 

def items = map.findAll { key, value -> value.contains('a') } 
def items = list.findAll { p -> p.lastName == 'Doe' }

None seem to populate the option list in the "key:value" format, which results in strange behaviour with the option set on screen. More on that here.

There are also examples that use this findAll logic:

ParticipationTypeOptions.findAll {
it.value in ["Informal Remarks", "Keynote Address", "Speech", "Report"]
}.collectEntries {
[(it.optionId.toString()): it.value]
}

But it also results in an error.

Unsupported type class java.util.LinkedHashMap in setFieldOptions()

My versions are:

  • Scriptrunner 5.1.6
  • JIRA 7.1.9

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Artemy Matvienko
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 Leaders.
Mar 08, 2019

Nvm, The map isn't the issue, that's just how dump() displays things.

TAGS
AUG Leaders

Atlassian Community Events