Hello,
We have the following use-case:
- text field called "DoD"
- text field called "Acceptance Criteria"
- checklist field called "Story DoD" (from here: https://marketplace.atlassian.com/apps/1211562/checklist-for-jira?hosting=server&tab=overview)
When "acceptance criteria" is filled in, then the text field "DoD" should get the text:
"Acceptance Criteria defined" to it.
When all the checkboxes in "Story DoD" are filled in, the text field "DoD" (same one as above), should get the text "All checkboxes checked" appended to it.
First I tried with two listeners, but then I realized that the update of one of them can trigger the other and vice-versa.
I am having problems putting them together in just on script.
What I managed so far is below:
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.security.JiraAuthenticationContext
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def fieldConfigSchemeManager = ComponentAccessor.getFieldConfigSchemeManager()
def issue = event.issue as MutableIssue
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def DoD= ComponentAccessor.customFieldManager.getCustomFieldObjectByName("DoD")
def DoDValue = issue.getCustomFieldValue(DoD)
String appendedmessage1 = 'All the checkboxes in the Story DoD field are checked'
def StoryCheckbox = customFieldManager.getCustomFieldObjectByName("Story DoD")
def config = fieldConfigSchemeManager.getRelevantConfig(issue, StoryCheckbox)
def allOptions = optionsManager.getOptions(config)
def criteria = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Acceptance Criteria")
def criteriavalue = issue.getCustomFieldValue(criteria)
String appendedmessage2 = 'Acceptance Criteria defined'
Boolean alreadyAddedMessage1 = criteriavalue.indexOf(appendedmessage1) != -1
Boolean alreadyAddedMessage2 = criteriavalue.indexOf(appendedmessage2) != -1
I am having problems putting the condition in place.
Any help is appreciated.
Thank you!