Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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 Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

138 views 1 2
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you