I have a Custom field which is of type CheckBox.
What i want is, if all options of that checkbox custom field are selected, then only that post function should run.
Could some one please help me
What should the post function exactly do?
I personally would use Scriptrunner add-on. It has many build in post functions: See:
https://scriptrunner.adaptavist.com/latest/jira/builtin-scripts.html#_post_functions
Post Function will run a hidden transition based on condition being true.
Condition is checkbox field shall have all the options ticked.
So need to create a groovy expression for checking that all options are ticked in the custom field
/Himanshu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See the answer of alexey:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customFields = customFieldManager.getCustomFieldObjects(issue)
customFields.each {cf ->
if (cf.name == '<CUSTOMFIELDNAME>' ) {
return true;
} else {
return false;
}
}
*It is not working*
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Have you tried Alexeys corrected code snippet?
def customFieldManager = componentManager.getCustomFieldManager() def customFields = customFieldManager.getCustomFieldObjects(issue) def values = [] customFields.each {cf -> if (cf.getName() =~ "Check_" && cf.getCustomFieldType().getName() == "Multi Checkboxes") { values += cf.getValue(issue)*.toString() } def validChecks = ['CFO', 'CTO'] //add all your required options here return values.containsAll(validChecks) ? true : false
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It gives an error that
Spread Operator can be used only on Collection type
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hmm, how many options do you have?
You could check on each:
cfValues['<Your Field>']*.value in ['Option1', 'Option2', ...]
or maybe
cfValues['<Your Field>']*.value.contains("Option1") && cfValues['<Your Field>']*.value.contains("Option2") && ...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.