Hello,
like the title suggests, i need a listener that checks a Checkbox if certain custom fields have been edited. Anybody knows something similar that i can use or has some suggestions?
Thank you in advance
I see you are trying to use scriptrunner to achieve this. But I think automation for JIRA might be your best bet and is easy to configure. Both plugins offer customfield changed event in their listeners but Automation for JIRA offers the ability to capture specific field easily. You can then update the checkbox field as you see fit using the rule.
Hi @Sebastian Gastager ,
You can add this script in a Issue Updated listener :
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.util.DefaultIssueChangeHolderimport com.atlassian.jira.issue.ModifiedValuedef customFieldChanged = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Name of your custom field"}if (customFieldChanged){def optionsManager = ComponentAccessor.optionsManagerint checkBoxFieldId = 13000def checkBoxField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(checkBoxFieldId)def checkboxFieldConfig = checkBoxField.getRelevantConfig(issue) def options = optionsManager.getOptions(checkboxFieldConfig)def optionsToSet = options.findAll { it.value in ["option1_to_check", "option2_to_check"] } def checkBoxFieldValue = issue.getCustomFieldValue(checkBoxField)checkBoxField.updateValue(null, issue, new ModifiedValue(checkBoxFieldValue, optionsToSet), new DefaultIssueChangeHolder()) }
Antoine
Thx for your answer, i tried it but it shows an error in last line, when i try to execute it it gives me this error
The following log information was produced by this execution. Use statements like:log.info("...") to record logging information.
2019-09-06 09:44:51,907 ERROR [runner.AbstractScriptListener]: ************************************************************************************* 2019-09-06 09:44:51,908 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.issue.IssueEvent, file: <inline script> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script383.groovy: 17: expecting '}', found '' @ line 17, column 125. w DefaultIssueChangeHolder()) ^ 1 error
ok i found the mistake, its just a } at the end, but it still doesnt check my Box. I replaced
"Name of your custom field"
with my custom field name that should be checked for changes
I replaced this ID with the ID of my checkbox field
int checkBoxFieldId = 13000
And i replaced this with the option of my Custom Field that should be checked like this
it.value in ["My_Option"]
What am i doing wrong?
You should check the logs to see if the code fails, and if it correctly enters the if condition when you edit the field.
It looks like you're new here. Sign in or register to get started.