Hi All
We set a multi-choice field in jira. We expect different question types to see different choice values. I know that scriptrunner behaviours can implement this, but the effect is still the same after I set it
My statement Settings are as follows:
def field = getFieldByName('Product test')
field.setFormBalue(['test1','test2'])
field.setFieldOptions(['test1'])
I tried the above two methods, but none of them worked, and the field still showed all the option values
Hi @arno ,
Something like this should work:
def selectField = getFieldByName('Product test')
selectField.setFieldOptions(['test1'])
(i) You should see only test1 option when creating/editing issue
What is your Jira and Scriptrunner version? can you share a screenshot from your behavior? have you set the mapping to the correct project and issue type? is Product test a single select field?
Hi @Sayed Bares [ServiceRocket]
Thank you for your reply
I have found the cause of the problem, because I did not store the corresponding code in the field "Product test" configuration
I would like to ask if I can add some conditions to limit the display of the options, for example, when I select "test" in the custom field (Product), the product test option values are test1 and test2
My current configuration is as follows
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@arno I know exactly what you mean and to achieve real time editing, you will just need to add a script for your field which you want to check it in real time in this case it should be Product field and the script should look something like this:
def formField = getFieldById(getFieldChanged())
def ProductTest = getFieldByName('Product test')
def Product = formField.getValue()
if (Product == "test") {
ProductTest.setFieldOptions(['test1','test2'])
}
else
{
ProductTest.setFieldOptions(['test1','test2','test3'])
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can also refer to this documentation for more info :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Sayed Bares [ServiceRocket]
Thank you for your reply
According to your method, I have tried, which is exactly the result I need, thank you for your help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The issue is that #setFieldOptions() expects a Map as parameter (id:value kind of a thing), or iterable list of Options whereas ['xx'] in groovy would be a String array (or list, idk).
More importantly though check https://library.adaptavist.com for new scripts, it contains your use case here: https://library.adaptavist.com/entity/basics-behaviours-set-multi-select-options-value
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Earning the Mindful Member badge proves you know how to lead with kindness, plus it enters you into a giveaway for exclusive Atlassian swag. Take the quiz, grab the badge, and comment on our announcement article to spread the good vibes!
Start here
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.