i'm trying to set up a "send a custom email" script runner post function and I struggle to define the script of the condition to be met.
the condition is based on a checkboxes custom field. The field should be equal to a specific value.
I tried to select "Has string custom field value equal to " in the suggested examples but it does not work and I click Preview, the condition is set as false.
would you have any idea of the right code to write for a checkboxes custom field?
thanks in advance
You may find it easier to use the cfValues map which is passed in:
As Thanos said, with checkboxes it can be multiple. To check for a single specific checkbox being checked, and no others, you'd use:
cfValues['Name of field']*.value == ['An item']
Below there is a script where you can use in order to get the checkbox values
import com.atlassian.jira.component.ComponentAccessor import java.util.ArrayList def customField2 = customFieldManager.getCustomFieldObjectByName("checkbox") ArrayList listOfCheckBoxValues = issue.getCustomFieldValue(customField2) as ArrayList if (!listOfCheckBoxValues) return false if (listOfCheckBoxValues*.value.contains("option1")) return true else return false
A note. By default you can select more than one boxes therefore you always get a list of selected values. In case you want to use radio buttons where by default you can select only one value the script will be slightly different. Please let me know if you need further assistance.
Hello, Community! My name is Gosia and I'm a Product Manager on Jira Server and Data Center here at Atlassian. Since 2002 when we launched our public issue tracker, jira.atlass...
Connect with like-minded Atlassian users at free events near you!Find a group
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.Start an AUG
You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs