Cannot find matching method

Kirill December 21, 2020

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

0 votes
Italo Qualisoni [e-Core]
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.
December 21, 2020

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