Script error : restrict field values based on another field values selection

Amine Tanboura April 18, 2023
Hello team,
I am using scriptrunner behaviour in order to restrict field values based on another field values selection
I have an error, can you please check how to resolve it
Error :
 com.onresolve.jira.groovy.user.FormField#setFieldOptions(java.util.Map <?, java.lang.String>) with arguments [java.util.Map <java.lang.Object, java.lang.Object>]
import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

 

@BaseScript FieldBehaviours fieldBehaviours



int instanceId = 15950
def instance = getFieldById("customfield_15950")
def instanceValue = instance.getValue()



int numberId = 14953
def number = getFieldById("customfield_14953")

 

def optionsManager = ComponentAccessor.getOptionsManager()
def numberCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(numberId)
def numberConfig = numberCustomField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(numberConfig)

 

if (instanceValue == "Full"){

 

def map = ["2 Hours"]
def optionsMap = options.findAll {
it.value in map // list of options you want to show
}.collectEntries {
[
(it.optionId.toString()) : it.value
]
}
// error message : number.setFieldOptions(optionsMap)
}
[Static type checking] - Cannot call com.onresolve.jira.groovy.user.FormField#setFieldOptions(java.util.Map <?, java.lang.String>) with arguments [java.util.Map <java.lang.Object, java.lang.Object>]
else {
number.setFieldOptions(options)
}

1 answer

1 vote
Amine Tanboura April 28, 2023

Can someone please help me on this?

Amine Tanboura June 1, 2023

Hello Reddy,

I saw this and I asked for help, but no one is responding.

Regards

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.13
TAGS
AUG Leaders

Atlassian Community Events