Add a condition within listener.

Iryna Pazharytskaya February 16, 2023

Hi,

 

I am currently working on creating a listener that would set a text custom field to a value on all issue events. The code I foulnd is this:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

// the name of the custom field to update
final customFieldName = 'TextFieldA'

// the new value of the field
final newValue = 'I love Groovy !'

def customFieldManager = ComponentAccessor.customFieldManager
def issue = event.issue

def customField = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
assert customField : "Could not find custom field with name $customFieldName"

customField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customField), newValue), new DefaultIssueChangeHolder())

 

Is there any way to introduce a condition here that would check the value (second drop down) of the cascading field and depending on it set TextFieldA to a particular value?

 

Best,

 

Iryna

0 answers

Suggest an answer

Log in or Sign up to answer