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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Cannot find matching method

We are using Scriptrunner Behavior to restrict custom field value, and resieve this error

[Static type checking] - Cannot find matching method
com.onresolve.jira.groovy.user.FormField#contains(java.lang.String).
Pleas check if the declared type is correct and if the method exists.
Possible solutions: toString(), toString(), toString(), notify() @ line 16, column 5.

_____________________________________________________
_____________________________________________________

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*

def selectcf1 = getFieldByName("AA")

def selectcf2 = getFieldByName("BB")

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customField1 = customFieldManager.getCustomFieldObject(selectcf1.getFieldId())
def customField2 = customFieldManager.getCustomFieldObject(selectcf2.getFieldId())
def config = customField2.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)


if (selectcf1.contains("123")) {

def optionsMap = options.findAll {
it.value in ["234"]
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
selectcf2.setFieldOptions(optionsMap)
}

1 answer

Hi @Kirill ,

I think there isn't a contains method in FormField class

https://scriptrunner.adaptavist.com/6.16.0/jira/behaviours-api-quickref.html

Can you try instead use something like

selectcf1.getValue(), by the documentation this will gets the value that is current in the form. For certain fields, this does do some conversions.

  • Select fields, radio buttons, checkboxes, etc. the string value will be returned, or a List of string values.

  • Versions or Components fields the Version or Component objects(s) will be returned.

  • Linked Issues field (id: "issuelinks-issues") will always return an array, even an empty one.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,072 views 8 28
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you