Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Error message didn't shown to issue with subtasks



I have a listener 'issue updated' that catch the event of changing issue type, check some fields of the issue, and display an error message.

This code worked ok, Instead a scenario which the issue has subtask.

I put logs inside the code, and I can see the UserMessageUtil.error line is read but isn't display in the issue view..

This is my code:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.mail.Email;
import com.atlassian.mail.server.MailServerManager;
import com.atlassian.mail.server.SMTPMailServer;
import com.atlassian.jira.ComponentManager

Issue issue = event.getIssue()
def issueType=issue.getIssueType().name;
IssueManager issueManager = ComponentAccessor.getComponent(IssueManager.class)

def sub = issue.getSubTaskObjects();
log.warn sub
def SubIssue = ComponentAccessor.getIssueManager().getIssueObject(sub[0].toString());
log.warn SubIssue
def issueCur= SubIssue.getParentObject();
log.warn issueCur;
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "issuetype"}
log.warn change;
def newString = change.newstring;
def oldString = change.oldstring;

log.warn newString
log.warn oldString

//old type is Bug-Customer
if((newString.toString()=='Story' || newString.toString()=='Bug-Internal' || newString.toString()=='Doc Story' || newString.toString()=='Integration'
|| newString.toString()=='QVR' || newString.toString()=='Epic' || newString.toString()=='UX Story' || newString.toString()=='Feature'
|| newString.toString()=='Theme') && (oldString.toString()=='Bug-Customer'))
log.warn 1;
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def Salesforce = issueCur.getCustomFieldValue(customFieldManager.getCustomFieldObject("customfield_14309"));
log.warn Salesforce

log.warn 5
UserMessageUtil.error("<div style='color:red;'><b>Your move has changed the Issue Type for an Issue that has an external Salesforce ID to an Issue Type that is not synchronized with Salesforce and should not have a Salesforce ID.<br>Please contact a Jira administrator for more information.</b></div>");
log.warn 55




0 answers

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira

Online AMA this week: Your project management questions answered by Jira Design Lead James Rotanson

We know that great teams require amazing project management chops. It's no surprise that great teams who use Jira have strong project managers, effective workflows, and secrets that bring planning ...

196 views 1 6
Read article

Atlassian Community Events