Hi i have written a listener which first updates a value of the field based on other fields on the issue creation as well as on the issue update. The field is getting changed.
Also i have written a query to show a pop-up message whenever the field is set to Major.
But the pop message is not coming when i am changing the value of other 2 fields which in turn sets the value of other field to Major on the view screen .
the pop -up message is coming when i am clicking the edit button and then changing the value of other 2 fields which in turn sets the value of other field to Major.
pfb code -
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import org.apache.log4j.Logger
import org.apache.log4j.Level
log.setLevel(Level.INFO)
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.event.type.EventDispatchOption
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.getIssueManager()
MutableIssue issue = event.issue as MutableIssue;
def cfds = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Criticality Level'};
String cfdsv = issue.getCustomFieldValue(cfds);
log.info (cfdsv)
def pqrs = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Severity'};
String pqrsv = issue.getCustomFieldValue(pqrs);
log.info (pqrsv)
def abcd = customFieldManager.getCustomFieldObjects(issue).findByName('Incident Classification')
log.info (abcd)
def fieldConfig = abcd.getRelevantConfig(issue)
if (("Very High".equals(cfdsv)) && ("Very High".equals(pqrsv)))
{
def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'Major' }
log.info("In IF Block")
issue.setCustomFieldValue(abcd, value)
UserMessageUtil.success("This is a Major Incident")
log.info(value)
}
else if (("Very High".equals(cfdsv)) && ("High".equals(pqrsv)))
{
def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'Major' }
log.info("If 1")
issue.setCustomFieldValue(abcd, value)
UserMessageUtil.success("This is a Major Incident")
log.info(value)
}
else if (("High".equals(cfdsv)) && ("Very High".equals(pqrsv)))
{
def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'Major' }
log.info("If 2")
issue.setCustomFieldValue(abcd, value)
UserMessageUtil.success("This is a Major Incident")
log.info(value)
}
else if (("NA".equals(cfdsv)) && ("Very High".equals(pqrsv)))
{
def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'Major' }
log.info("If 3")
issue.setCustomFieldValue(abcd, value)
UserMessageUtil.success("This is a Major Incident")
log.info(value)
}
else
{
def value = ComponentAccessor.optionsManager.getOptions(fieldConfig)?.find { it.toString() == 'Minor' }
issue.setCustomFieldValue(abcd, value)
log.info(value)
}
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false);
Hi Nic since you are the expert i would like to know what is wrong in my code and why the pop-up message is not coming when changing the value of the fields on the view screen.
Even selected as - Issue creation, Issue updation.
But the pop -up message is coming when clicking on the edit button and then changing the value of the fields.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.