Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Error message didn't shown to issue with subtasks

Dan27 January 15, 2019

Hello,

 

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
if(sub!=null)
{
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

if(Salesforce!=null)
{
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
TAGS
AUG Leaders

Atlassian Community Events