Hi,
I'm learning groovy scripting (early days) and testing script runner post functions.
I have one custom multi checkbox field that has email addresses as the options.
I'm trying the approach if the checkbox contains certain text to then to create a variable which will be the email address and then add this to a single line text custom field.
Reason being I'm using the JEMH plugin and you can use custom fields as the "To:" addresses but it doesn't support multi checkboxes but normal text fields are fine.
So far I'm just testing with one if statement and trying to update the custom text field with one variable.
I believe I haven't quite grasped checking the value in the source custom multi checkbox field. So would be thankful for a steer in the right direction. The post function with the script below doesn't cause an error in the logs but doesn't update the text field.
Thanks,
David
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.CustomFieldManager; ComponentManager componentManager = ComponentManager.getInstance(); CustomFieldManager customFieldManager = componentManager.getCustomFieldManager(); CustomField source = customFieldManager.getCustomFieldObject("customfield_10468"); CustomField target = customFieldManager.getCustomFieldObject("customfield_11521"); sourceValue = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10468")) if (['sourceValue']*.value.contains("Support")) { supportValue = "support@domain.com,"; issue.setCustomFieldValue(target, supportValue) }
This looks very wrong:
if (['sourceValue']*.value.contains("Support"))
you probably meant:
if (sourceValue*.value.contains("Support"))
Hi Jamie, Thank you for your assistance, though it maybe a small thing it has helped me progress. After some thinking and more learning I have ended up with the following which seems more suited to solving what I needed for looking for all the options selected in the checkbox. With the script below I can now get all the options from the checkbox and put these into a string, formatted in a way I can use for the JEMH email addresses. Thanks again, a lot of my learning comes from your comments in this Atlassian answers site.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
import com.atlassian.jira.ComponentManager; import com.atlassian.jira.issue.fields.CustomField; import com.atlassian.jira.issue.CustomFieldManager; ComponentManager componentManager = ComponentManager.getInstance(); CustomFieldManager customFieldManager = componentManager.getCustomFieldManager(); CustomField source = customFieldManager.getCustomFieldObject("customfield_10468"); CustomField target = customFieldManager.getCustomFieldObject("customfield_11521"); sourceValue = issue.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_10468")) if(sourceValue !=null){ contentsSourceValue = sourceValue.join(", ") issue.setCustomFieldValue(target, contentsSourceValue) }
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.