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)
}
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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.