Hi All,
I have written a script in a listener (Event - Issue created, issue updated) which updates a custom field named as - Incident Classification on the basis of 2 other fields as soon as the issue gets created or updated.
the field "Incident classification"can have 2 values - Major , Minor.
I have written another listener in which i need to have a pop-up message coming as soon as the value of "Incident Classification" field is set to "Major".
I am running the listener on the issue create and issue update event but i am not getting the pop-up message always.
Problem statement -
1) as soon as the issue gets created in the view screen i can see that the field Incident classification has been set to Major but the pop-up message does not appears.
2) No pop up message coming - When i am updating the other 2 fields the value of Incident classification gets changed automatically and is set to Major but still the pop up message is not appearing.
Pop-up message is coming only when i am editing the issue by going to edit screen and changing the value of the other 2 fields which in turn changes the value of Incident Classification field and the pop-up message is coming.
Please let me know why the below listener is not working properly - 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
MutableIssue issue = event.issue as MutableIssue;
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.getIssueManager()
def cfds = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Incident Classification'};
String cfdsv = issue.getCustomFieldValue(cfds);
log.info (cfdsv)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false);
if ("Major".equals(cfdsv))
{
log.info (cfdsv)
UserMessageUtil.success("Since this is a Major Incident, please follow the defined Escalation Process")
}
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.